Module: Ms::Mascot::Formats::Xml::Utils
- Defined in:
- lib/ms/mascot/formats/xml.rb
Instance Method Summary collapse
Instance Method Details
#hashify(nodes, cast = true) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/ms/mascot/formats/xml.rb', line 8 def hashify(nodes, cast=true) nodes.inject({}) do |hash, node| value = node.content hash[node.name] = cast ? objectify(value) : value hash end end |
#objectify(value) ⇒ Object
16 17 18 19 20 21 22 23 24 25 |
# File 'lib/ms/mascot/formats/xml.rb', line 16 def objectify(value) case value when nil nil when /\A\d+(\.\d+)?\z/ $1 ? value.to_f : value.to_i else value end end |