Class: Price

Inherits:
Object
  • Object
show all
Defined in:
lib/quick_travel/price.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#centsObject

Returns the value of attribute cents.



2
3
4
# File 'lib/quick_travel/price.rb', line 2

def cents
  @cents
end

#currencyObject

Returns the value of attribute currency.



2
3
4
# File 'lib/quick_travel/price.rb', line 2

def currency
  @currency
end

#dollarsObject

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_textObject



11
12
13
# File 'lib/quick_travel/price.rb', line 11

def formatted_text
  "#{@dollars}"
end