class RexleDiff::HashedDoc
Public Class Methods
new(node)
click to toggle source
# File lib/rexle-diff.rb, line 21 def initialize(node) @node = node @node.hashed = hash(node) + hashit(node).inject(:+) end
Public Instance Methods
hash(element)
click to toggle source
# File lib/rexle-diff.rb, line 32 def hash(element) attributes = element.attributes.clone %i(created last_modified).each {|x| attributes.delete x} [element.name, attributes, element.text.to_s.strip].hash end
hashit(node)
click to toggle source
# File lib/rexle-diff.rb, line 40 def hashit(node) a = node.elements.map do |element| row = hash element if element.has_elements? r = hashit(element) sum = row + r.inject(:+) element.hashed = sum sum else element.hashed = row row end end end
to_doc()
click to toggle source
# File lib/rexle-diff.rb, line 28 def to_doc() @node end