Class: OpenExchangeRate::Api
- Inherits:
-
Object
- Object
- OpenExchangeRate::Api
- Defined in:
- lib/open-exchange-rate/open-exchange-rate.rb
Instance Attribute Summary collapse
-
#app_id ⇒ Object
Returns the value of attribute app_id.
-
#https ⇒ Object
Returns the value of attribute https.
Instance Method Summary collapse
- #currencies ⇒ Object
-
#initialize(app_id: "insert_app_id", https: false) ⇒ Api
constructor
A new instance of Api.
- #latest ⇒ Object
Constructor Details
#initialize(app_id: "insert_app_id", https: false) ⇒ Api
5 6 7 8 9 10 11 |
# File 'lib/open-exchange-rate/open-exchange-rate.rb', line 5 def initialize( app_id: "insert_app_id", https: false) @app_id = app_id @https = https end |
Instance Attribute Details
#app_id ⇒ Object
Returns the value of attribute app_id.
3 4 5 |
# File 'lib/open-exchange-rate/open-exchange-rate.rb', line 3 def app_id @app_id end |
#https ⇒ Object
Returns the value of attribute https.
3 4 5 |
# File 'lib/open-exchange-rate/open-exchange-rate.rb', line 3 def https @https end |
Instance Method Details
#currencies ⇒ Object
25 26 27 28 29 |
# File 'lib/open-exchange-rate/open-exchange-rate.rb', line 25 def currencies url = "http://openexchangerates.org/api/currencies.json" # no app_id required http = Curl.get url Oj.load(http.body_str) end |
#latest ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/open-exchange-rate/open-exchange-rate.rb', line 13 def latest if @https prefix = "https" else prefix = "http" end url = "#{prefix}://openexchangerates.org/api/latest.json?app_id=#{app_id}" http = Curl.get url Oj.load(http.body_str) end |