Module: Aranha::Parsers::Html::Node::Default::NumericSupport
- Defined in:
- lib/aranha/parsers/html/node/default/numeric_support.rb
Instance Method Summary collapse
- #float_optional_value(node, xpath) ⇒ Object
- #float_value(node, xpath) ⇒ Object
- #integer_optional_value(node, xpath) ⇒ Object
- #integer_value(node, xpath) ⇒ Object
- #us_decimal_optional_value(node, xpath) ⇒ Object
- #us_decimal_value(node, xpath) ⇒ Object
Instance Method Details
#float_optional_value(node, xpath) ⇒ Object
32 33 34 |
# File 'lib/aranha/parsers/html/node/default/numeric_support.rb', line 32 def float_optional_value(node, xpath) parse_float(node, xpath, false) end |
#float_value(node, xpath) ⇒ Object
28 29 30 |
# File 'lib/aranha/parsers/html/node/default/numeric_support.rb', line 28 def float_value(node, xpath) parse_float(node, xpath, true) end |
#integer_optional_value(node, xpath) ⇒ Object
22 23 24 25 26 |
# File 'lib/aranha/parsers/html/node/default/numeric_support.rb', line 22 def integer_optional_value(node, xpath) r = string_value(node, xpath) m = /\d+/.match(r) m ? m[0].to_i : nil end |
#integer_value(node, xpath) ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/aranha/parsers/html/node/default/numeric_support.rb', line 12 def integer_value(node, xpath) r = string_value(node, xpath) return nil if r.blank? m = /\d+/.match(r) raise "Integer not found in \"#{r}\"" unless m m[0].to_i end |
#us_decimal_optional_value(node, xpath) ⇒ Object
40 41 42 |
# File 'lib/aranha/parsers/html/node/default/numeric_support.rb', line 40 def us_decimal_optional_value(node, xpath) parse_us_decimal(node, xpath, false) end |
#us_decimal_value(node, xpath) ⇒ Object
36 37 38 |
# File 'lib/aranha/parsers/html/node/default/numeric_support.rb', line 36 def us_decimal_value(node, xpath) parse_us_decimal(node, xpath, true) end |