Class: ForexDataClient
- Inherits:
-
Object
- Object
- ForexDataClient
- Defined in:
- lib/forex_quotes.rb
Instance Method Summary collapse
- #convert(from, to, quantity) ⇒ Object
- #fetch(api_call) ⇒ Object
- #getMarketStatus ⇒ Object
- #getQuotes(symbols) ⇒ Object
- #getSymbols ⇒ Object
-
#initialize(api_key) ⇒ ForexDataClient
constructor
A new instance of ForexDataClient.
- #quota ⇒ Object
Constructor Details
#initialize(api_key) ⇒ ForexDataClient
Returns a new instance of ForexDataClient.
5 6 7 |
# File 'lib/forex_quotes.rb', line 5 def initialize(api_key) @api_key = api_key end |
Instance Method Details
#convert(from, to, quantity) ⇒ Object
25 26 27 |
# File 'lib/forex_quotes.rb', line 25 def convert(from, to, quantity) self.fetch('convert?cache=false&from=' + from + '&to=' + to + '&quantity=' + quantity.to_s) end |
#fetch(api_call) ⇒ Object
9 10 11 |
# File 'lib/forex_quotes.rb', line 9 def fetch(api_call) JSON.parse(HTTP.get("https://forex.1forge.com/1.0.2/" + api_call + "&api_key=" + @api_key)) end |
#getMarketStatus ⇒ Object
29 30 31 |
# File 'lib/forex_quotes.rb', line 29 def getMarketStatus() self.fetch('market_status?cache=false') end |
#getQuotes(symbols) ⇒ Object
21 22 23 |
# File 'lib/forex_quotes.rb', line 21 def getQuotes(symbols) self.fetch('quotes?cache=false&pairs=' + symbols.join(',')) end |
#getSymbols ⇒ Object
17 18 19 |
# File 'lib/forex_quotes.rb', line 17 def getSymbols() self.fetch('symbols?cache=false') end |
#quota ⇒ Object
13 14 15 |
# File 'lib/forex_quotes.rb', line 13 def quota() self.fetch('quota?cache=false') end |