Class: DiasporaFederation::Parsers::XmlParser

Inherits:
BaseParser
  • Object
show all
Defined in:
lib/diaspora_federation/parsers/xml_parser.rb

Overview

This is a parser of XML serialized object. Explanations about the XML data format can be found here.

Direct Known Subclasses

RelayableXmlParser

Instance Method Summary collapse

Methods inherited from BaseParser

#initialize

Constructor Details

This class inherits a constructor from DiasporaFederation::Parsers::BaseParser

Instance Method Details

#parse(root_node) ⇒ Array[1]

Returns comprehensive data for an entity instantiation.

Parameters:

  • root_node (Nokogiri::XML::Element)

    root XML node of the XML representation of the entity

Returns:

  • (Array[1])

    comprehensive data for an entity instantiation

See Also:



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/diaspora_federation/parsers/xml_parser.rb', line 14

def parse(root_node)
  from_xml_sanity_validation(root_node)

  hash = root_node.element_children.uniq(&:name).to_h {|child|
    property, type = find_property_for(child.name)
    if property
      value = parse_element_from_node(child.name, type, root_node)
      [property, value]
    else
      [child.name, child.text]
    end
  }

  [hash]
end