Class: ModelPresenter::Money

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(amount_in_cents) ⇒ Money

Returns a new instance of Money


5
6
7
# File 'lib/model_presenter/money.rb', line 5

def initialize(amount_in_cents)
  @amount_in_cents = amount_in_cents
end

Instance Attribute Details

#amount_in_centsObject (readonly)

Returns the value of attribute amount_in_cents


3
4
5
# File 'lib/model_presenter/money.rb', line 3

def amount_in_cents
  @amount_in_cents
end

Instance Method Details

#to_dollarObject


9
10
11
12
# File 'lib/model_presenter/money.rb', line 9

def to_dollar
  amount_in_dollar = amount_in_cents.to_f / 100
  '%.2f' % amount_in_dollar
end