class Monee::Config
Singleton class that can be initiated only once to hold the configuration values @see ruby-doc.org/stdlib-2.2.2/libdoc/singleton/rdoc/Singleton.html
Constants
- DEFAULT_RATE
this is default rate, against this value other currency rates are calculated
Attributes
base_currency[RW]
currency_rates[RW]
Public Instance Methods
available_currencies()
click to toggle source
retrieves all the currencies configured including the base
@return [Array]
# File lib/monee/config.rb, line 41 def available_currencies set_default_rate currency_rates.keys end
exists?(code)
click to toggle source
checks if the code exists in the config
@param code [String] code of the currency @return [Boolean]
# File lib/monee/config.rb, line 34 def exists?(code) available_currencies.include?(code) end
fetch_rate(code)
click to toggle source
fetches the rate of a currency by code of the currency
@param code [String] code of the currency @return [Numeric]
# File lib/monee/config.rb, line 26 def fetch_rate(code) currency_rates[code] end
reset()
click to toggle source
to reset the configuration values @return [void]
# File lib/monee/config.rb, line 17 def reset self.base_currency = nil self.currency_rates = nil end
set_default_rate()
click to toggle source
sets the default rate to the base currency as 1
@return [void]
# File lib/monee/config.rb, line 49 def set_default_rate currency_rates[base_currency] = DEFAULT_RATE end