Class: RPath::Adapters::Oga
- Inherits:
-
RPath::Adapter
- Object
- RPath::Adapter
- RPath::Adapters::Oga
- Defined in:
- lib/rpath/adapters/oga.rb
Instance Method Summary collapse
-
#adapts?(graph) ⇒ Boolean
Returns
true
iffgraph
is an Oga::XML::Document or an Oga::XML::Element. -
#adjacent(vertex) ⇒ Array<Oga::XML::Element>
Returns the child elements of the given node.
-
#attribute(vertex, name) ⇒ String?
Returns the value of the named attribute on the given node.
-
#content(vertex) ⇒ String?
Returns the text content of the given node.
-
#name(vertex) ⇒ String
Returns the name of the given node.
Methods inherited from RPath::Adapter
Instance Method Details
#adapts?(graph) ⇒ Boolean
Returns true
iff graph
is an Oga::XML::Document or an Oga::XML::Element
11 12 13 |
# File 'lib/rpath/adapters/oga.rb', line 11 def adapts?(graph) graph.is_a?(::Oga::XML::Element) || graph.is_a?(::Oga::XML::Document) end |
#adjacent(vertex) ⇒ Array<Oga::XML::Element>
Returns the child elements of the given node
25 26 27 |
# File 'lib/rpath/adapters/oga.rb', line 25 def adjacent(vertex) vertex.children.select { |child| child.is_a?(::Oga::XML::Element) } end |
#attribute(vertex, name) ⇒ String?
Returns the value of the named attribute on the given node.
33 34 35 36 37 38 39 40 |
# File 'lib/rpath/adapters/oga.rb', line 33 def attribute(vertex, name) if vertex.is_a?(::Oga::XML::Element) attr = vertex.attr(name) attr && attr.value else nil end end |
#content(vertex) ⇒ String?
Returns the text content of the given node.
45 46 47 |
# File 'lib/rpath/adapters/oga.rb', line 45 def content(vertex) vertex.is_a?(::Oga::XML::Element) ? vertex.text : nil end |
#name(vertex) ⇒ String
Returns the name of the given node
18 19 20 |
# File 'lib/rpath/adapters/oga.rb', line 18 def name(vertex) vertex.is_a?(::Oga::XML::Element) ? vertex.name : nil end |