Class: Egg::Money
- Inherits:
-
Object
- Object
- Egg::Money
- Defined in:
- lib/egg/money.rb
Instance Method Summary collapse
-
#initialize(money) ⇒ Money
constructor
A new instance of Money.
- #to_f ⇒ Object
Constructor Details
#initialize(money) ⇒ Money
Returns a new instance of Money.
3 4 5 6 7 8 |
# File 'lib/egg/money.rb', line 3 def initialize(money) money = money.sub(/£/, '').gsub(/,/, '') md = money.match(/(\d+\.\d+) ([A-Z]+)/) @money = md ? Float(md[1]) : 0 @money = -@money if md && md[2] == 'DR' end |
Instance Method Details
#to_f ⇒ Object
9 10 11 |
# File 'lib/egg/money.rb', line 9 def to_f @money end |