Class: Coronet::MessageFormat::XmlMessageFormat
- Defined in:
- lib/coronet/message_format/xml_message_format.rb
Instance Method Summary collapse
-
#pack(hash, root = 'opt') ⇒ Object
transform hash to xml string.
-
#unpack(xml_str) ⇒ Object
transform xml string to hash.
Methods inherited from Base
Instance Method Details
#pack(hash, root = 'opt') ⇒ Object
transform hash to xml string
14 15 16 |
# File 'lib/coronet/message_format/xml_message_format.rb', line 14 def pack(hash, root='opt') XmlSimple.xml_out(hash, noattr: true, rootname: root).strip! end |
#unpack(xml_str) ⇒ Object
transform xml string to hash
5 6 7 8 9 10 11 |
# File 'lib/coronet/message_format/xml_message_format.rb', line 5 def unpack(xml_str) # puts "--- xml message format attempting to unpack: #{xml_str}" unpacked = XmlSimple.xml_in(xml_str, forcearray: false, keeproot: true) unpacked = unpacked['opt'] if unpacked.has_key? 'opt' # puts "--- unpacked: #{unpacked}" unpacked end |