Class: CoinMarket::Client
- Inherits:
-
Object
- Object
- CoinMarket::Client
- Defined in:
- lib/coin_market/client.rb
Constant Summary collapse
- @@api_version =
'v1'
- @@base_uri =
"https://api.coinmarketcap.com/v1"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#convert ⇒ Object
Returns the value of attribute convert.
-
#limit ⇒ Object
Returns the value of attribute limit.
-
#start ⇒ Object
Returns the value of attribute start.
Instance Method Summary collapse
-
#initialize(options = {}) {|_self| ... } ⇒ Client
constructor
A new instance of Client.
- #request(endpoint, id = nil, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Client
Returns a new instance of Client.
10 11 12 13 14 15 16 |
# File 'lib/coin_market/client.rb', line 10 def initialize( = {}) .each do |key, value| instance_variable_set("@#{key}", value) end yield(self) if block_given? end |
Instance Attribute Details
#api_key ⇒ Object
Returns the value of attribute api_key.
8 9 10 |
# File 'lib/coin_market/client.rb', line 8 def api_key @api_key end |
#convert ⇒ Object
Returns the value of attribute convert.
8 9 10 |
# File 'lib/coin_market/client.rb', line 8 def convert @convert end |
#limit ⇒ Object
Returns the value of attribute limit.
8 9 10 |
# File 'lib/coin_market/client.rb', line 8 def limit @limit end |
#start ⇒ Object
Returns the value of attribute start.
8 9 10 |
# File 'lib/coin_market/client.rb', line 8 def start @start end |
Instance Method Details
#request(endpoint, id = nil, options = {}) ⇒ Object
18 19 20 21 22 23 24 |
# File 'lib/coin_market/client.rb', line 18 def request(endpoint, id=nil, ={}) res = read_url(build_url(endpoint, id, )) JSON.parse(res) rescue OpenURI::HTTPError => e puts "ERROR: #{e}" [] end |