Class: Hpricot::Elements
- Inherits:
-
Object
- Object
- Hpricot::Elements
- Defined in:
- lib/duck_punches/hpricot.rb
Instance Method Summary collapse
-
#to_boolean ⇒ Object
Return boolean true if the value of an element is the string ‘true’.
-
#to_money ⇒ Object
Assume a Google standard money node with a currency attribute.
Instance Method Details
#to_boolean ⇒ Object
Return boolean true if the value of an element is the string ‘true’.
20 21 22 |
# File 'lib/duck_punches/hpricot.rb', line 20 def to_boolean inner_html == 'true' end |
#to_money ⇒ Object
Assume a Google standard money node with a currency attribute.
Returns a Ruby Money object.
9 10 11 12 13 14 |
# File 'lib/duck_punches/hpricot.rb', line 9 def to_money dollar_amount = inner_html cents = (dollar_amount.to_f * 100).round currency = first[:currency] Money.new(cents, currency) end |