Class: OXR::Configuration
- Inherits:
-
Object
- Object
- OXR::Configuration
- Defined in:
- lib/oxr/configuration.rb
Constant Summary collapse
- ENDPOINT =
'https://openexchangerates.org/api/'.freeze
Instance Attribute Summary collapse
-
#app_id ⇒ Object
Returns the value of attribute app_id.
-
#base ⇒ Object
Returns the value of attribute base.
- #currencies ⇒ Object
- #historical(date) ⇒ Object
- #latest ⇒ Object
- #usage ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#app_id ⇒ Object
Returns the value of attribute app_id.
7 8 9 |
# File 'lib/oxr/configuration.rb', line 7 def app_id @app_id end |
#base ⇒ Object
Returns the value of attribute base.
7 8 9 |
# File 'lib/oxr/configuration.rb', line 7 def base @base end |
#currencies ⇒ Object
10 11 12 13 14 |
# File 'lib/oxr/configuration.rb', line 10 def currencies @currencies || URI.join(ENDPOINT, 'currencies.json').tap do |uri| uri.query = "app_id=#{app_id}" end.to_s end |
#historical(date) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/oxr/configuration.rb', line 16 def historical(date) @historical || URI.join(ENDPOINT, "historical/#{date.strftime('%F')}.json").tap do |uri| uri.query = "app_id=#{app_id}" uri.query += "&base=#{base}" if base end.to_s end |
#latest ⇒ Object
23 24 25 26 27 28 |
# File 'lib/oxr/configuration.rb', line 23 def latest @latest || URI.join(ENDPOINT, 'latest.json').tap do |uri| uri.query = "app_id=#{app_id}" uri.query += "&base=#{base}" if base end.to_s end |
#usage ⇒ Object
30 31 32 33 34 |
# File 'lib/oxr/configuration.rb', line 30 def usage @usage || URI.join(ENDPOINT, 'usage.json').tap do |uri| uri.query = "app_id=#{app_id}" end.to_s end |
Instance Method Details
#reset_sources ⇒ Object
36 37 38 39 40 41 |
# File 'lib/oxr/configuration.rb', line 36 def reset_sources @currencies = nil @historical = nil @latest = nil @usage = nil end |