Class: Fat::Money
- Inherits:
-
Object
- Object
- Fat::Money
- Defined in:
- lib/fat/money.rb
Instance Attribute Summary collapse
-
#cents ⇒ Object
Returns the value of attribute cents.
Instance Method Summary collapse
- #==(money) ⇒ Object
-
#initialize(string) ⇒ Money
constructor
A new instance of Money.
Constructor Details
#initialize(string) ⇒ Money
Returns a new instance of Money.
8 9 10 11 12 |
# File 'lib/fat/money.rb', line 8 def initialize string stripped = '' string.each {|char| stripped += char if char.between?('0', '9') or char == '.'} @cents = (100 * stripped.to_f).to_i end |
Instance Attribute Details
#cents ⇒ Object
Returns the value of attribute cents.
7 8 9 |
# File 'lib/fat/money.rb', line 7 def cents @cents end |
Instance Method Details
#==(money) ⇒ Object
13 14 15 |
# File 'lib/fat/money.rb', line 13 def == money @cents == money.cents end |