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 35 36 37 38 39 40 41 42 43 44 45 |
# 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 if e.text('strong').to_s =~ /^\s+$/ then colour_strong(e, :bg_gray) else colour_strong(e, :red) end ' - '.red + ' ' + e.plaintext when :ins puts e.text('strong').to_s.inspect if e.text('strong').to_s =~ /^\s+$/ then colour_strong(e, :bg_green) else colour_strong(e) {|x| x.light_green} end ' + '.green + ' ' + e.plaintext when :span ' ' + ' ' + e.plaintext else ' ' + ' ' + e.plaintext end end @s = a2.join("\n") end |
Instance Method Details
#to_s ⇒ Object
47 48 49 |
# File 'lib/diffyc32.rb', line 47 def to_s() @s end |