class FixerApiClient::Currency
Constants
- BASE_CURRENCY
- BASE_CURRENCY_AMOUNT
Attributes
friendly_name[R]
symbol[R]
value[R]
Public Class Methods
new(value, symbol, friendly_name)
click to toggle source
# File lib/fixer_api_client/currency.rb, line 8 def initialize(value, symbol, friendly_name) @value = value @symbol = symbol @friendly_name = friendly_name end
Public Instance Methods
inspect()
click to toggle source
# File lib/fixer_api_client/currency.rb, line 15 def inspect "#{value} #{friendly_name}" end
Private Instance Methods
currency_rates()
click to toggle source
# File lib/fixer_api_client/currency.rb, line 41 def currency_rates @currency_rates ||= FixerApiClient::CurrencyData.rates end
current_rate()
click to toggle source
# File lib/fixer_api_client/currency.rb, line 37 def current_rate currency_rates[symbol.upcase] end
to_base()
click to toggle source
this will convert the value we have to the base currency (EUR) because API free tier only allows to set EUR as base, so, let's say we have 1 USD, this, will convert it to 0.80 EUR
# File lib/fixer_api_client/currency.rb, line 33 def to_base value / current_rate end