Class: Price
- Inherits:
-
Object
- Object
- Price
- Defined in:
- lib/quick_travel/price.rb
Instance Attribute Summary collapse
-
#cents ⇒ Object
Returns the value of attribute cents.
-
#currency ⇒ Object
Returns the value of attribute currency.
-
#dollars ⇒ Object
Returns the value of attribute dollars.
Instance Method Summary collapse
- #formatted_text ⇒ Object
-
#initialize(hash) ⇒ Price
constructor
A new instance of Price.
Constructor Details
#initialize(hash) ⇒ Price
Returns a new instance of Price.
4 5 6 7 8 9 |
# File 'lib/quick_travel/price.rb', line 4 def initialize(hash) cents = hash['cents'].to_i @dollars = cents / 100 @cents = cents % 100 @currency = hash['currency'] end |
Instance Attribute Details
#cents ⇒ Object
Returns the value of attribute cents.
2 3 4 |
# File 'lib/quick_travel/price.rb', line 2 def cents @cents end |
#currency ⇒ Object
Returns the value of attribute currency.
2 3 4 |
# File 'lib/quick_travel/price.rb', line 2 def currency @currency end |
#dollars ⇒ Object
Returns the value of attribute dollars.
2 3 4 |
# File 'lib/quick_travel/price.rb', line 2 def dollars @dollars end |
Instance Method Details
#formatted_text ⇒ Object
11 12 13 |
# File 'lib/quick_travel/price.rb', line 11 def formatted_text "#{@dollars}" end |