Class: ModelPresenter::Money
- Inherits:
-
Object
- Object
- ModelPresenter::Money
- Defined in:
- lib/model_presenter/money.rb
Instance Attribute Summary collapse
-
#amount_in_cents ⇒ Object
readonly
Returns the value of attribute amount_in_cents.
Instance Method Summary collapse
-
#initialize(amount_in_cents) ⇒ Money
constructor
A new instance of Money.
- #to_dollar ⇒ Object
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_cents ⇒ Object (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_dollar ⇒ Object
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 |