Class: ApiSports::Resource
- Inherits:
-
Object
- Object
- ApiSports::Resource
- Defined in:
- lib/api_sports/resource.rb
Direct Known Subclasses
CountriesResource, FixturesResource, LeaguesResource, OddsResource, StandingsResource, TeamsResource, TimezonesResource, VenuesResource
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #get_request(url, params: {}, headers: {}) ⇒ Object
- #get_single_resource(url, params: {}, headers: {}) {|response| ... } ⇒ Object
- #handle_response(response) ⇒ Object
-
#initialize(client) ⇒ Resource
constructor
A new instance of Resource.
Constructor Details
#initialize(client) ⇒ Resource
Returns a new instance of Resource.
7 8 9 |
# File 'lib/api_sports/resource.rb', line 7 def initialize(client) @client = client end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
5 6 7 |
# File 'lib/api_sports/resource.rb', line 5 def client @client end |
Instance Method Details
#get_request(url, params: {}, headers: {}) ⇒ Object
11 12 13 |
# File 'lib/api_sports/resource.rb', line 11 def get_request(url, params: {}, headers: {}) handle_response client.connection.get(url, params, headers) end |
#get_single_resource(url, params: {}, headers: {}) {|response| ... } ⇒ Object
15 16 17 18 |
# File 'lib/api_sports/resource.rb', line 15 def get_single_resource(url, params: {}, headers: {}, &dig_block) response = get_request(url, params: params, headers: headers) yield(response) end |