Class: Hpricot::Elements

Inherits:
Object
  • Object
show all
Defined in:
lib/duck_punches/hpricot.rb

Instance Method Summary collapse

Instance Method Details

#to_booleanObject

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_moneyObject

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