Module: AIXM::Concerns::XMLBuilder
- Includes:
- Memoize
- Included in:
- AIXM::Component, AIXM::Component::FATO::Direction, AIXM::Component::Geometry::Circle, AIXM::Component::Geometry::Point, AIXM::Component::Geometry::RhumbLine, AIXM::Component::Runway::Direction, Feature::Airport::UsageLimitation, Feature::Airport::UsageLimitation::Condition
- Defined in:
- lib/aixm/concerns/xml_builder.rb
Overview
Adds the XML builder wrapped to generate a document fragment.
Instance Method Summary collapse
-
#build_fragment {|Nokogiri::XML::Builder| ... } ⇒ Nokogiri::XML::DocumentFragment
Build a XML document fragment.
-
#to_uid ⇒ Nokogiri::XML::DocumentFragment
UID fragment.
-
#to_xml ⇒ String
AIXM or OFMX fragment.
Methods included from Memoize
Instance Method Details
#build_fragment {|Nokogiri::XML::Builder| ... } ⇒ Nokogiri::XML::DocumentFragment
Build a XML document fragment.
12 13 14 15 16 17 18 19 |
# File 'lib/aixm/concerns/xml_builder.rb', line 12 def build_fragment Nokogiri::XML::DocumentFragment.parse('').tap do |fragment| Nokogiri::XML::Builder.with(fragment) do |builder| yield builder end fragment.elements.each { _1.add_next_sibling("\n") } # add newline between tags on top level end end |
#to_uid ⇒ Nokogiri::XML::DocumentFragment
Returns UID fragment.
22 23 24 |
# File 'lib/aixm/concerns/xml_builder.rb', line 22 def to_uid(...) build_fragment { add_uid_to(_1, ...) } end |
#to_xml ⇒ String
Returns AIXM or OFMX fragment.
28 29 30 |
# File 'lib/aixm/concerns/xml_builder.rb', line 28 def to_xml(...) build_fragment { add_to(_1, ...) }.to_xml.strip.concat("\n") end |