class Shale::Adapter::Ox::Node

Wrapper around Ox::Element API

@api private

Public Class Methods

new(node) click to toggle source

Initialize object with Ox element

@param [::Ox::Element] node Ox element

@api private

# File lib/shale/adapter/ox.rb, line 110
def initialize(node)
  @node = node
end

Public Instance Methods

attributes() click to toggle source

Return all attributes associated with the node

@return [Hash]

@api private

# File lib/shale/adapter/ox.rb, line 135
def attributes
  @node.attributes
end
children() click to toggle source

Return node’s element children

@return [Array<Shale::Adapter::Ox::Node>]

@api private

# File lib/shale/adapter/ox.rb, line 144
def children
  @node
    .nodes
    .filter { |e| e.is_a?(::Ox::Element) }
    .map { |e| self.class.new(e) }
end
name() click to toggle source

Return fully qualified name of the node in the format of namespace:name when the node is namespaced or just name when it’s not

@return [String]

@example without namespace

node.name # => Bar

@example with namespace

node.name # => foo:Bar

@api private

# File lib/shale/adapter/ox.rb, line 126
def name
  @node.name
end
text() click to toggle source

Return first text child of a node

@return [String]

@api private

# File lib/shale/adapter/ox.rb, line 156
def text
  @node.text
end