Class: EarthTools::XML::Element

Inherits:
Object
  • Object
show all
Defined in:
lib/earth_tools/xml/element.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#xmlObject

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