Class: CTFC::API::ApiTemplate
- Inherits:
-
Object
- Object
- CTFC::API::ApiTemplate
- Defined in:
- lib/ctfc/api/apitemplate.rb
Overview
Template for other sources. Every file in api dir should extend this class. Automatically call method #process to send api request after initialization. This mean every source should include method #process, that will be executed after initialization.
Direct Known Subclasses
Constant Summary collapse
- MAX_RETRY =
max number of requests to send
3
Instance Attribute Summary collapse
-
#response ⇒ Object
readonly
Returns the value of attribute response.
Class Method Summary collapse
-
.[](fiat, coins) ⇒ Hash
Initialize new instance, send request and return response hash.
Instance Method Summary collapse
-
#initialize(fiat, coins) ⇒ Object
constructor
Construct response hash from given arguments, and start counting requests.
Constructor Details
#initialize(fiat, coins) ⇒ Object
Construct response hash from given arguments, and start counting requests. Call private method #process to extract data from web.
33 34 35 36 37 |
# File 'lib/ctfc/api/apitemplate.rb', line 33 def initialize(fiat, coins) @response = { fiat: fiat, coins: coins, success: false } @counter = 0 process end |
Instance Attribute Details
#response ⇒ Object (readonly)
Returns the value of attribute response.
17 18 19 |
# File 'lib/ctfc/api/apitemplate.rb', line 17 def response @response end |
Class Method Details
.[](fiat, coins) ⇒ Hash
Initialize new instance, send request and return response hash.
48 49 50 |
# File 'lib/ctfc/api/apitemplate.rb', line 48 def self.[](fiat, coins) new(fiat, coins).response end |