Class: BigBlueButton::BigBlueButtonHash
- Inherits:
-
Hash
- Object
- Hash
- BigBlueButton::BigBlueButtonHash
- Defined in:
- lib/bigbluebutton_hash_to_xml.rb
Class Method Summary collapse
Class Method Details
.from_xml(xml_io) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/bigbluebutton_hash_to_xml.rb', line 6 def from_xml(xml_io) begin # we'll not use 'KeyToSymbol' because it doesn't symbolize the keys for node attributes opts = { 'ForceArray' => false, 'ForceContent' => false } # hash = XmlSimple.xml_in(xml_io, opts) return symbolize_keys(hash) rescue Exception => e raise BigBlueButtonException.new("Impossible to convert XML to hash. Error: #{e.}") end end |
.symbolize_keys(arg) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bigbluebutton_hash_to_xml.rb', line 17 def symbolize_keys(arg) case arg when Array arg.map { |elem| symbolize_keys elem } when Hash Hash[ arg.map { |key, value| k = key.is_a?(String) ? key.to_sym : key v = symbolize_keys value [k,v] }] else arg end end |