Class: Interfacets::Test::Js::Receivers::React::Node::XmlParser

Inherits:
Object
  • Object
show all
Defined in:
lib/interfacets/test/js/receivers/react/node/xml_parser.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json, validation_engine:) ⇒ XmlParser

Returns a new instance of XmlParser.



13
14
15
16
# File 'lib/interfacets/test/js/receivers/react/node/xml_parser.rb', line 13

def initialize(json, validation_engine:)
  @json = json
  @validation_engine = validation_engine
end

Instance Attribute Details

#json ⇒ Object (readonly)

Returns the value of attribute json.



12
13
14
# File 'lib/interfacets/test/js/receivers/react/node/xml_parser.rb', line 12

def json
  @json
end

#validation_engine ⇒ Object (readonly)

Returns the value of attribute validation_engine.



12
13
14
# File 'lib/interfacets/test/js/receivers/react/node/xml_parser.rb', line 12

def validation_engine
  @validation_engine
end

Instance Method Details

#call ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/interfacets/test/js/receivers/react/node/xml_parser.rb', line 18

def call
  xml = Nokogiri::XML.fragment("<Facet/>")
  json
    .dig("streams", "default", "dom")
    .map { parse_element(_1) }
    .each { xml.add_child(_1) }
  xml
end