class NodeValueExtractor
Attributes
node_extractor[R]
Public Class Methods
new(node_extractor)
click to toggle source
# File lib/src/extractor.rb, line 78 def initialize(node_extractor) @node_extractor = node_extractor end
Public Instance Methods
attr_values(path, attributes)
click to toggle source
# File lib/src/extractor.rb, line 82 def attr_values(path, attributes) return attributes.map { |atr| attr_value(path, atr) } if attributes.is_a? Array return tag_count(path) if attributes == :tag_count attr_value(path, attributes) end
tag_count(path)
click to toggle source
# File lib/src/extractor.rb, line 89 def tag_count(path) node_extractor.extract(path).size end
tag_values(base_path, paths)
click to toggle source
# File lib/src/extractor.rb, line 93 def tag_values(base_path, paths) return tag_value(base_path) unless paths.is_a? Array paths.map { |path| tag_value([base_path, path].flatten.compact.join("/")) } end
Private Instance Methods
attr_value(path, att)
click to toggle source
# File lib/src/extractor.rb, line 107 def attr_value(path, att) node_raw_value node_extractor.extract(path).attribute(att) end
node_raw_value(node)
click to toggle source
# File lib/src/extractor.rb, line 111 def node_raw_value(node) NodeValue.new(node).raw_value end
tag_value(path)
click to toggle source
# File lib/src/extractor.rb, line 103 def tag_value(path) node_raw_value node_extractor.extract(path) end