Class: Teodoro::XML
- Inherits:
-
Object
- Object
- Teodoro::XML
- Defined in:
- lib/teodoro/xml.rb
Instance Method Summary collapse
-
#*(path) ⇒ Object
rubocop:disable Naming/BinaryOperatorParameterName.
- #[](*path) ⇒ Object
Instance Method Details
#*(path) ⇒ Object
rubocop:disable Naming/BinaryOperatorParameterName
27 28 29 |
# File 'lib/teodoro/xml.rb', line 27 def *(path) # rubocop:disable Naming/BinaryOperatorParameterName xml.css("*/#{path}").map { |node| self.class.new(Nokogiri::XML(node.to_s)) } end |
#[](*path) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/teodoro/xml.rb', line 13 def [](*path) node_set = xml.css("*/#{path.join('/')}") raise if node_set.size > 1 return if node_set.size.zero? node = node_set[0] if node.css('*').empty? node_set.text else self.class.new(Nokogiri::XML(node.to_s)) end end |