I'm using nokogiri and my object graph when looping looks like:
#<Nokogiri::XML::Element:0x3fe7b34a49c8 name="dt" children=[#
<Nokogiri::XML::Element:0x3fe7b34a4720 name="a" attributes=[#
<Nokogiri::XML::Attr:0x3fe7b34a46bc name="href" value="http://www.example.com">, #
<Nokogiri::XML::Attr:0x3fe7b34a4694 name="add_date" value="1246334352997870">] children=[#
<Nokogiri::XML::Text:0x3fe7b34a39c4 "Example.com Website ">]>, #
<Nokogiri::XML::Text:0x3fe7b34a35f0 "\n">,
I want to load this information into this class:
class LinkInfo
attr_accessor :href, :add_date, :text
end
href = http://www.example.com
add_date = 1246334352997870
text = "example.com website"
Is there an elegant way to do this, I'm currently looping through the children, and doing things with if statements to see if I am at the right tag name etc.
I know in ruby you can see if a value is in a collection using contains?, but I also want to then get the value of that.