Method: OpenNebula::XMLElement#to_hash

Defined in:
lib/opennebula/xml_element.rb

#to_hashHash

Returns a hash representing the resource.

Returns:

  • (Hash)

    a hash representing the resource



362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
# File 'lib/opennebula/xml_element.rb', line 362

def to_hash
    hash = {}

    if NOKOGIRI
        if @xml.instance_of?(Nokogiri::XML::NodeSet)
            @xml.each { |c|
                if c.element?
                    build_hash(hash, c)
                end
            }
        else
            build_hash(hash, @xml)
        end
    else
        build_hash(hash, @xml)
    end

    hash
end