Class: ExchangerYahoo0
- Inherits:
-
ExchangerBase
- Object
- ExchangerBase
- ExchangerYahoo0
- Defined in:
- lib/mrpin/core/currency_exchanger/yahoo/exchanger_yahoo0.rb
Instance Method Summary collapse
- #get_rate(from_currency, to_currency) ⇒ Object
-
#initialize ⇒ ExchangerYahoo0
constructor
A new instance of ExchangerYahoo0.
Constructor Details
#initialize ⇒ ExchangerYahoo0
Returns a new instance of ExchangerYahoo0.
13 14 15 16 |
# File 'lib/mrpin/core/currency_exchanger/yahoo/exchanger_yahoo0.rb', line 13 def initialize super @exchanger_api = ManagerRemoteHttp.new(url: 'https://quote.yahoo.com') end |
Instance Method Details
#get_rate(from_currency, to_currency) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mrpin/core/currency_exchanger/yahoo/exchanger_yahoo0.rb', line 20 def get_rate(from_currency, to_currency) params = { s: "#{from_currency}#{to_currency}=X", f: 'l1', e: '.csv' } response = @exchanger_api.get('d/quotes.csv', params) assert(response[:status] == EResponseType::ERT_OK, response) rate_string = response[:response] rate_string.strip! rate_string.to_f end |