lib/aranha/parsers/html/node/default.rb in aranha-parsers-0.17.1 vs lib/aranha/parsers/html/node/default.rb in aranha-parsers-0.18.0
- old
+ new
@@ -9,24 +9,38 @@
module Node
class Default < ::Aranha::Parsers::Html::Node::Base
require_sub __FILE__, include_modules: true
def array_value(node, xpath)
- r = node.xpath(xpath).map { |n| n.text.strip }
+ r = node_set_value(node, xpath).map { |n| n.text.strip }
r.join('|')
end
def join_value(node, xpath)
m = ''
- node.xpath(xpath).each do |n|
+ node_set_value(node, xpath).each do |n|
m << n.text.strip
end
m
end
def duration_value(node, xpath)
m = /(\d+) m/.match(join_value(node, xpath))
m ? m[1].to_i : nil
+ end
+
+ # @param node [Nokogiri::XML::Node]
+ # @param xpath [String]
+ # @return [Nokogiri::XML::NodeSet]
+ def node_set_value(node, xpath)
+ node.xpath(xpath)
+ end
+
+ # @param node [Nokogiri::XML::Node]
+ # @param xpath [String]
+ # @return [Nokogiri::XML::Node]
+ def node_value(node, xpath)
+ node.at_xpath(xpath)
end
end
end
end
end