Class: Aranha::Parsers::Html::Node::Default

Inherits:
Base
  • Object
show all
Defined in:
lib/aranha/parsers/html/node/default.rb,
lib/aranha/parsers/html/node/default/string_support.rb,
lib/aranha/parsers/html/node/default/numeric_support.rb

Defined Under Namespace

Modules: NumericSupport, StringSupport

Instance Attribute Summary

Attributes inherited from Base

#fields

Instance Method Summary collapse

Methods inherited from Base

#initialize, #parse

Constructor Details

This class inherits a constructor from Aranha::Parsers::Html::Node::Base

Instance Method Details

#array_value(node, xpath) ⇒ Object



13
14
15
16
# File 'lib/aranha/parsers/html/node/default.rb', line 13

def array_value(node, xpath)
  r = node.xpath(xpath).map { |n| n.text.strip }
  r.join('|')
end

#duration_value(node, xpath) ⇒ Object



26
27
28
29
# File 'lib/aranha/parsers/html/node/default.rb', line 26

def duration_value(node, xpath)
  m = /(\d+) m/.match(join_value(node, xpath))
  m ? m[1].to_i : nil
end

#join_value(node, xpath) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/aranha/parsers/html/node/default.rb', line 18

def join_value(node, xpath)
  m = ''
  node.xpath(xpath).each do |n|
    m << n.text.strip
  end
  m
end