class NodeValue

Attributes

node[R]

Public Class Methods

new(node) click to toggle source
# File lib/src/extractor.rb, line 117
def initialize(node)
  @node = node
end

Public Instance Methods

raw_value() click to toggle source
# File lib/src/extractor.rb, line 121
def raw_value
  return "" unless node

  node_size = node.try(:size).to_i
  return node.map(&:text) if node_size > 1
  return node.first if node_size == 1 && contains_children?

  node.text
end

Private Instance Methods

contains_children?() click to toggle source
# File lib/src/extractor.rb, line 135
def contains_children?
  node.first.try(:children).any? { |child| child.is_a? Nokogiri::XML::Element }
end