Class: ForexRateAPI::Client

Inherits:
Object
  • Object
show all
Includes:
Connection, Endpoints, Request
Defined in:
lib/forexrateapi/client.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Endpoints

#change, #convert, #fetchHistorical, #fetchLive, #fetchSymbols, #hourly, #ohlc, #timeframe, #usage

Methods included from Request

#delete, #get, #post, #put

Constructor Details

#initialize(options = {}) ⇒ Client

Returns a new instance of Client.



11
12
13
14
15
16
17
18
19
# File 'lib/forexrateapi/client.rb', line 11

def initialize(options = {})
  ForexRateAPI::Config::ATTRIBUTES.each do |key|
    send("#{key}=", options[key] || ForexRateAPI.config.send(key))
  end
  if options[:server]
    self.endpoint = Config::SERVERS[options[:server]] || Config::SERVERS['us']
  end
  @logger ||= ForexRateAPI::Logger.logger
end

Class Method Details

.configObject



31
32
33
# File 'lib/forexrateapi/client.rb', line 31

def config
  Config
end

.configureObject



27
28
29
# File 'lib/forexrateapi/client.rb', line 27

def configure
  block_given? ? yield(Config) : Config
end

Instance Method Details

#setServer(server) ⇒ Object



21
22
23
24
# File 'lib/forexrateapi/client.rb', line 21

def setServer(server)
  self.endpoint = Config::SERVERS[server] || Config::SERVERS['us']
  @connection = nil
end