Class: EarthTools::XML::Element
- Inherits:
-
Object
- Object
- EarthTools::XML::Element
- Defined in:
- lib/earth_tools/xml/element.rb
Instance Attribute Summary collapse
-
#xml ⇒ Object
Returns the value of attribute xml.
Instance Method Summary collapse
- #[](element) ⇒ Object
-
#initialize(xml) ⇒ Element
constructor
A new instance of Element.
Constructor Details
#initialize(xml) ⇒ Element
Returns a new instance of Element.
6 7 8 |
# File 'lib/earth_tools/xml/element.rb', line 6 def initialize(xml) @xml = xml end |
Instance Attribute Details
#xml ⇒ Object
Returns the value of attribute xml.
4 5 6 |
# File 'lib/earth_tools/xml/element.rb', line 4 def xml @xml end |
Instance Method Details
#[](element) ⇒ Object
10 11 12 13 14 |
# File 'lib/earth_tools/xml/element.rb', line 10 def [](element) element = @xml.at(element) return unless element element.children.any? { |c| c.element? } ? EarthTools::XML::Element.new(element) : element.text end |