Class: Shale::Adapter::Ox::Node Private
- Inherits:
-
Object
- Object
- Shale::Adapter::Ox::Node
- Defined in:
- lib/shale/adapter/ox/node.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Wrapper around Ox::Element API
Instance Method Summary collapse
-
#attributes ⇒ Hash
private
Return all attributes associated with the node.
-
#children ⇒ Array<Shale::Adapter::Ox::Node>
private
Return node’s element children.
-
#initialize(node) ⇒ Node
constructor
private
Initialize object with Ox element.
-
#name ⇒ String
private
Return name of the node in the format of prefix:name when the node is namespaced or just name when it’s not.
-
#namespaces ⇒ Hash<String, String>
private
Return namespaces defined on document (Not supported by Ox).
-
#parent ⇒ nil
private
Return node’s parent (Not supported by OX).
-
#text ⇒ String
private
Return first text child of a node.
Constructor Details
#initialize(node) ⇒ Node
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize object with Ox element
15 16 17 |
# File 'lib/shale/adapter/ox/node.rb', line 15 def initialize(node) @node = node end |
Instance Method Details
#attributes ⇒ Hash
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return all attributes associated with the node
52 53 54 |
# File 'lib/shale/adapter/ox/node.rb', line 52 def attributes @node.attributes end |
#children ⇒ Array<Shale::Adapter::Ox::Node>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return node’s element children
70 71 72 73 74 75 |
# File 'lib/shale/adapter/ox/node.rb', line 70 def children @node .nodes .filter { |e| e.is_a?(::Ox::Element) } .map { |e| self.class.new(e) } end |
#name ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return name of the node in the format of prefix:name when the node is namespaced or just name when it’s not
43 44 45 |
# File 'lib/shale/adapter/ox/node.rb', line 43 def name @node.name end |
#namespaces ⇒ Hash<String, String>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return namespaces defined on document (Not supported by Ox)
27 28 29 |
# File 'lib/shale/adapter/ox/node.rb', line 27 def namespaces {} end |
#parent ⇒ nil
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return node’s parent (Not supported by OX)
61 62 63 |
# File 'lib/shale/adapter/ox/node.rb', line 61 def parent # :noop: end |
#text ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Return first text child of a node
82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/shale/adapter/ox/node.rb', line 82 def text texts = @node.nodes.map do |e| case e when ::Ox::CData e.value when ::String e end end texts.compact.first end |