Class: CoinMarketCapitalization::Base
- Inherits:
-
Object
- Object
- CoinMarketCapitalization::Base
- Defined in:
- lib/coin_market_capitalization/base.rb
Overview
Base class
Direct Known Subclasses
Blockchain, Content, Cryptocurrency, Exchange, Fiat, GlobalMetrics, Key
Instance Attribute Summary collapse
-
#adapter ⇒ Object
readonly
Returns the value of attribute adapter.
-
#api_key ⇒ Object
readonly
Returns the value of attribute api_key.
-
#base_url ⇒ Object
readonly
Returns the value of attribute base_url.
Instance Method Summary collapse
- #connection ⇒ Object
-
#initialize(api_key:, base_url:, adapter: Faraday.default_adapter) ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(api_key:, base_url:, adapter: Faraday.default_adapter) ⇒ Base
Returns a new instance of Base.
11 12 13 14 15 |
# File 'lib/coin_market_capitalization/base.rb', line 11 def initialize(api_key:, base_url:, adapter: Faraday.default_adapter) @api_key = api_key @base_url = base_url @adapter = adapter end |
Instance Attribute Details
#adapter ⇒ Object (readonly)
Returns the value of attribute adapter.
9 10 11 |
# File 'lib/coin_market_capitalization/base.rb', line 9 def adapter @adapter end |
#api_key ⇒ Object (readonly)
Returns the value of attribute api_key.
9 10 11 |
# File 'lib/coin_market_capitalization/base.rb', line 9 def api_key @api_key end |
#base_url ⇒ Object (readonly)
Returns the value of attribute base_url.
9 10 11 |
# File 'lib/coin_market_capitalization/base.rb', line 9 def base_url @base_url end |
Instance Method Details
#connection ⇒ Object
17 18 19 20 21 22 23 24 |
# File 'lib/coin_market_capitalization/base.rb', line 17 def connection @connection ||= Faraday.new do |conn| conn.url_prefix = base_url conn.request :json conn.response :json, content_type: "application/json" conn.adapter adapter end end |