Class: Fat::Money

Inherits:
Object
  • Object
show all
Defined in:
lib/fat/money.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#centsObject

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