Here's one way to do it.  There are probably better ways.

rick@frodo:~/rubyscripts$ cat enum_contrast.rb
module Enumerable

        def contrast(enum, eql_val=nil)
                result = []
                self.zip(enum) { |a, b| result << (a.eql?(b) ? eql_val : b)}
                result
        end

        def ordered_contrast(enum, eql_val=nil)
                result = []
                diff = false
                self.zip(enum) do |a, b|
                        diff = diff || !a.eql?(b)
                        result << (diff ? b: eql_val)
                end
                result
        end

        def intersect(enum, diff_val=nil)
                result = []
                self.zip(enum) { |a, b| result << (a.eql?(b) ? b : diff_val)}
                result
        end

        def ordered_intersect(enum, diff_val=nil)
                result = []
                diff = false
                self.zip(enum) do |a, b|
                        diff = diff || !a.eql?(b)
                        result << (diff ? diff_val : b)
                end
                result
        end
end

        class String

                def to_chars_array
                        unpack('a'*length)
                end

                def contrast(str)
                        to_chars_array.contrast(str.to_chars_array,' ').join
                end

                def ordered_contrast(str)

to_chars_array.ordered_contrast(str.to_chars_array,' ').join
                end

                def intersect(str)
                        to_chars_array.intersect(str.to_chars_array,' ').join
                end

                def ordered_intersect(str)

to_chars_array.ordered_intersect(str.to_chars_array,' ').join
                end
        end

rick@frodo:~/rubyscripts$ cat test_enum_contrast.rb
require 'enum_contrast.rb'
require 'test/unit'

class TestSubranges < Test::Unit::TestCase

        def test_array_contrast
                assert_equal([ nil, nil, "c", nil ],
                             [ "a", "a", "b", "c" ].contrast([ "a",
"a", "c", "c" ]))

                assert_equal([ nil, nil, "b", nil ],
                             [ "a", "a", "c", "c" ].contrast([ "a",
"a", "b", "c" ]))

                assert_equal([ nil, nil, "c", nil ],
                             [ "a", "a", "b", "c" ].contrast([ "a",
"a", "c", "c" ]))

                assert_equal([ "a", "a", nil, "c" ],
                             [ nil, nil, "c", nil ].contrast([ "a",
"a", "c", "c" ]))
        end

        def test_array_ordered_contrast
                assert_equal([ nil, nil, "c","c" ],
                             [ "a", "a", "b", "c" ].ordered_contrast([
"a", "a", "c", "c" ]))

                assert_equal([ nil, nil, "b","c" ],
                             [ "a", "a", "c", "c" ].ordered_contrast([
"a", "a", "b", "c" ]))
        end

        def test_array_intersect
                assert_equal([ "a", "a", nil, "c" ],
                             [ "a", "a", "b", "c" ].intersect([ "a",
"a", "c", "c" ]))
        end

        def test_array_ordered_intersect
                assert_equal([ "a", "a", nil, nil ],
                             [ "a", "a", "b", "c"
].ordered_intersect([ "a", "a", "c", "c" ]))

        end

        def test_string_ordered_contrast
                assert_equal("  cc",
                             "aabc".ordered_contrast( "aacc" ))
        end

        def test_string_contrast
                assert_equal("  c ",
                             "aabc".contrast("aacc"))
        end

        def test_string_intersect
                assert_equal("aa c",
                             "aabc".intersect("aacc"))
        end

        def test_string_ordered_intersect
                assert_equal("aa  ",
                             "aabc".ordered_intersect("aacc"))
        end
end
rick@frodo:~/rubyscripts$ ruby test_enum_contrast.rb
Loaded suite test_enum_contrast
Started
........
Finished in 0.010052 seconds.

8 tests, 12 assertions, 0 failures, 0 errors
rick@frodo:~/rubyscripts$
-- 
Rick DeNatale

My blog on Ruby
http://talklikeaduck.denhaven2.com/