Skip to content

Instantly share code, notes, and snippets.

@benaskins
Created January 13, 2009 07:54
Show Gist options
  • Select an option

  • Save benaskins/46362 to your computer and use it in GitHub Desktop.

Select an option

Save benaskins/46362 to your computer and use it in GitHub Desktop.
class DataElement
attr_reader :value, :name
def initialize(name, xml_elem)
@name = name
@value = (!xml_elem || xml_elem.inner_html.blank?) ? "n/a" : xml_elem.inner_html
@attributes = xml_elem ? xml_elem.attributes : {}
end
def hash
(@name + @value).hash
end
def eql?(other)
self.is_a?(other.class) && self.name.eql?(other.name) && self.value.eql?(other.value)
end
def ==(other)
self.to_s == other.to_s
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment