Class: XMLObject::Adapters::LibXML::Element
- Inherits:
-
Base::Element
- Object
- Base::Element
- XMLObject::Adapters::LibXML::Element
- Defined in:
- lib/xml-object/adapters/libxml.rb
Overview
:nodoc:
Instance Attribute Summary
Attributes inherited from Base::Element
#attributes, #children, #name, #raw, #value
Instance Method Summary collapse
-
#initialize(xml) ⇒ Element
constructor
A new instance of Element.
Constructor Details
#initialize(xml) ⇒ Element
Returns a new instance of Element.
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/xml-object/adapters/libxml.rb', line 20 def initialize(xml) @raw, @name, @attributes = xml, xml.name, xml.attributes.to_h @element_nodes = xml.children.select { |c| c.element? } @text_nodes = xml.children.select { |c| c.text? }.map! { |c| c.to_s } @cdata_nodes = xml.children.select { |c| c.cdata? }.map! do |c| c.to_s.chomp(']]>').sub('<![CDATA[', '') end super end |