Class: DiffyC32
- Inherits:
-
Object
- Object
- DiffyC32
- Defined in:
- lib/diffyc32.rb
Instance Method Summary collapse
-
#initialize(s1, s2) ⇒ DiffyC32
constructor
A new instance of DiffyC32.
- #to_s ⇒ Object
Constructor Details
#initialize(s1, s2) ⇒ DiffyC32
Returns a new instance of DiffyC32.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/diffyc32.rb', line 13 def initialize(s1, s2) html = Diffy::Diff.new(s1, s2).to_s(:html) doc = Rexle.new(html) a = doc.root.xpath('ul/li/*') a2 = a.map do |e| txt = case e.name.to_sym when :del colour_strong(e, :red) ' - '.red + ' ' + e.plaintext when :ins colour_strong(e) {|x| x.light_green} ' + '.green + ' ' + e.plaintext when :span ' ' + ' ' + e.plaintext else ' ' + ' ' + e.plaintext end end @s = a2.join("\n") end |
Instance Method Details
#to_s ⇒ Object
36 37 38 |
# File 'lib/diffyc32.rb', line 36 def to_s() @s end |