Class: HabiticaClient::ApiBase
- Inherits:
-
Object
- Object
- HabiticaClient::ApiBase
- Defined in:
- lib/habitica_client/api_base.rb
Overview
The basis of all HabiticaClient endpoint objects.
All HabiticaClient endpoint objects need a reference to the http client so that we can make the API work using the dot syntax.
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Class Method Summary collapse
Instance Method Summary collapse
- #data ⇒ Object
- #endpoint ⇒ Object
-
#initialize(client) ⇒ ApiBase
constructor
A new instance of ApiBase.
Constructor Details
#initialize(client) ⇒ ApiBase
Returns a new instance of ApiBase.
11 12 13 |
# File 'lib/habitica_client/api_base.rb', line 11 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
9 10 11 |
# File 'lib/habitica_client/api_base.rb', line 9 def client @client end |
Class Method Details
.endpoint(url) ⇒ Object
23 24 25 |
# File 'lib/habitica_client/api_base.rb', line 23 def self.endpoint(url) instance_variable_set(:@endpoint, url) end |
Instance Method Details
#data ⇒ Object
15 16 17 |
# File 'lib/habitica_client/api_base.rb', line 15 def data @data ||= client.class.get(endpoint)['data'] end |
#endpoint ⇒ Object
19 20 21 |
# File 'lib/habitica_client/api_base.rb', line 19 def endpoint self.class.instance_variable_get(:@endpoint) end |