Your code block { |bike_elem| bike_elem.text.chomp if bike_elem.name == "name" }
doesn't seem to make sense inside the new
parameter list.
Where does bike_elem
come from? This is not valid Ruby in this context.
It's hard to give an answer here without knowing what your XML looks like.
But I would recommend using a XML library like Nokogiri, libxml, and then parse out
the name before you do the new
. Try using XPath.
rules.root.each_element do |node1|
case node1.name
when "Bike"
name = node1.attributes[....]
bike = Bike.new(node1.attributes['id'], node1.attributes['color'],name )
bikes.push bike
end
end