Using the diffy gem

require 'diffy'

string1 = <<-TXT
Hello how are you
I'm fine
That's great
TXT

#=> "Hello how are you\nI'm fine\nThat's great\n"

string2 = <<-TXT
Hello how are you?
I'm fine
That's swell
TXT

#=> "Hello how are you?\nI'm fine\nThat's swell\n"

puts Diffy::Diff.new(string1, string2)

output:

-Hello how are you
+Hello how are you?
 I'm fine
-That's great
+That's swell

Resources

Tags:
Source:
2212hrs.txt
Published:
25-12-2014 22:12