Class: NodeValue

Inherits:
Object
  • Object
show all
Defined in:
lib/src/extractor.rb

Instance Method Summary collapse

Constructor Details

#initialize(node) ⇒ NodeValue

Returns a new instance of NodeValue.



119
120
121
# File 'lib/src/extractor.rb', line 119

def initialize(node)
  @node = node
end

Instance Method Details

#raw_valueObject



123
124
125
126
127
128
129
130
131
# File 'lib/src/extractor.rb', line 123

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