class Shale::Adapter::REXML::Node

Wrapper around REXML::Element API

@api private

Public Class Methods

new(node) click to toggle source

Initialize object with REXML element

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

@api private

# File lib/shale/adapter/rexml.rb, line 111
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/rexml.rb, line 136
def attributes
  @node.attributes
end
children() click to toggle source

Return node’s element children

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

@api private

# File lib/shale/adapter/rexml.rb, line 145
def children
  @node
    .children
    .filter { |e| e.node_type == :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/rexml.rb, line 127
def name
  @node.expanded_name
end
text() click to toggle source

Return first text child of a node

@return [String]

@api private

# File lib/shale/adapter/rexml.rb, line 157
def text
  @node.text
end