Class: MoneyExchange::Client::OXR
- Inherits:
-
Object
- Object
- MoneyExchange::Client::OXR
- Defined in:
- lib/money_exchange/client/oxr.rb
Constant Summary collapse
- ENDPOINT =
'https://openexchangerates.org/api/'.freeze
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(app_id, iso_base = 'USD') ⇒ OXR
constructor
A new instance of OXR.
Constructor Details
#initialize(app_id, iso_base = 'USD') ⇒ OXR
Returns a new instance of OXR.
8 9 10 11 |
# File 'lib/money_exchange/client/oxr.rb', line 8 def initialize(app_id, iso_base = 'USD') @app_id = app_id @iso_base = iso_base end |
Instance Method Details
#data ⇒ Object
13 14 15 16 17 18 19 20 21 22 |
# File 'lib/money_exchange/client/oxr.rb', line 13 def data uri = URI.join(ENDPOINT, 'latest.json').tap do |uri| uri.query = "app_id=#{@app_id}" uri.query += "&base=#{@iso_base}" if @iso_base end.to_s response = open(uri) JSON.parse(response) end |