Class: Money::Bank::GoogleCurrency
- Inherits:
-
VariableExchange
- Object
- VariableExchange
- Money::Bank::GoogleCurrency
- Defined in:
- lib/money/bank/google_currency.rb
Constant Summary
- SERVICE_HOST =
"www.google.com"
- SERVICE_PATH =
"/ig/calculator"
Instance Attribute Summary (collapse)
-
- (Hash) rates
readonly
Stores the currently known rates.
Instance Method Summary (collapse)
-
- (Float) flush_rate(from, to)
Clears the specified rate stored in @rates.
-
- (Hash) flush_rates
Clears all rates stored in @rates.
- - (Float) get_google_rate(from, to) Deprecated Deprecated.
-
- (Float) get_rate(from, to)
Returns the requested rate.
Instance Attribute Details
- (Hash) rates (readonly)
Stores the currently known rates.
13 14 15 |
# File 'lib/money/bank/google_currency.rb', line 13 def rates @rates end |
Instance Method Details
- (Float) flush_rate(from, to)
Clears the specified rate stored in @rates.
44 45 46 47 48 49 |
# File 'lib/money/bank/google_currency.rb', line 44 def flush_rate(from, to) key = rate_key_for(from, to) @mutex.synchronize{ @rates.delete(key) } end |
- (Hash) flush_rates
Clears all rates stored in @rates
24 25 26 27 28 |
# File 'lib/money/bank/google_currency.rb', line 24 def flush_rates @mutex.synchronize{ @rates = {} } end |
- (Float) get_google_rate(from, to)
Deprecated.
Returns the requested rate after querying Google.
81 82 83 84 |
# File 'lib/money/bank/google_currency.rb', line 81 def get_google_rate(from, to) warn "#get_google_rate is deprecated, please use #get_rate" fetch_rate(from, to) end |
- (Float) get_rate(from, to)
Returns the requested rate.
62 63 64 65 66 |
# File 'lib/money/bank/google_currency.rb', line 62 def get_rate(from, to) @mutex.synchronize{ @rates[rate_key_for(from, to)] ||= fetch_rate(from, to) } end |