Class: Lutaml::Model::XmlAdapter::OgaDocument
- Inherits:
-
Document
- Object
- Document
- Lutaml::Model::XmlAdapter::OgaDocument
show all
- Defined in:
- lib/lutaml/model/xml_adapter/oga_adapter.rb
Instance Attribute Summary
Attributes inherited from Document
#root
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Document
#children, #declaration, #initialize, #namespace_attributes
Class Method Details
.parse(xml) ⇒ Object
9
10
11
12
13
|
# File 'lib/lutaml/model/xml_adapter/oga_adapter.rb', line 9
def self.parse(xml)
parsed = Oga.parse_xml(xml)
root = OgaElement.new(parsed)
new(root)
end
|
Instance Method Details
#to_h ⇒ Object
15
16
17
|
# File 'lib/lutaml/model/xml_adapter/oga_adapter.rb', line 15
def to_h
{ @root.name => parse_element(@root) }
end
|
#to_xml(options = {}) ⇒ Object
19
20
21
22
23
24
|
# File 'lib/lutaml/model/xml_adapter/oga_adapter.rb', line 19
def to_xml(options = {})
builder = Oga::XML::Builder.new
build_element(builder, @root, options)
xml_data = builder.to_xml
options[:declaration] ? declaration(options) + xml_data : xml_data
end
|