Sha256: b581b871ece84914b5e78a80a79028eedc795459e24b989886441285f847e91e

Contents?: true

Size: 894 Bytes

Versions: 3

Compression:

Stored size: 894 Bytes

Contents

class LibXML::XML::Node
  def elements
    result = []
    each_element { |e| result << e }
    return result
  end
  # if node2 contains at least all that I do
  def simpifation_of?(node2)
    return false if (self.name != node2.name)
    self.attributes.each do |attr|
      return false unless node2.attributes[attr.name] == attr.value
    end
    
    elems1 = self.elements
    elems2 = node2.elements
    return false if (elems1.length != elems2.length) 
    elems1.length.times do |i|
      unless 
        case elems1[i].node_type_name
          when 'text' 
            (elems1[i].to_s == elems2[i].to_s) 
          when 'element' 
            elems1[i].simpifation_of?(elems2[i])
          else true 
        end
      then 
        return false 
      end
    end
       
    return true
  end
  def equals?(node2)
    simpifation_of?(node2) and node2.simpifation_of?(self)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rspreadsheet-0.0.5 lib/class_extensions.rb
rspreadsheet-0.0.4 lib/class_extensions.rb
rspreadsheet-0.0.2 lib/class_extensions.rb