Class: FootStats::Resource
- Inherits:
-
Object
- Object
- FootStats::Resource
- Includes:
- AttributeAccessor
- Defined in:
- lib/foot_stats/resource.rb
Direct Known Subclasses
Championship, ChampionshipClassification, Live, Match, Narration, NarrationDetail, Player, Team
Class Method Summary collapse
-
.parse_response(response) ⇒ String
Return response parsed data.
-
.resource_key ⇒ String
Return the resource key that is fetch from the API response.
-
.resource_name ⇒ String
Return the resource name to request to FootStats.
-
.updated_response(response, options) ⇒ Array
Return parsed response if updated when requested updated data.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Resource
constructor
Waiting for ActiveModel::Model.
Methods included from AttributeAccessor
Constructor Details
#initialize(options = {}) ⇒ Resource
Waiting for ActiveModel::Model. =p
7 8 9 10 11 |
# File 'lib/foot_stats/resource.rb', line 7 def initialize(={}) .each do |key, value| send("#{key}=", value) if respond_to?("#{key}=") end end |
Class Method Details
.parse_response(response) ⇒ String
Return response parsed data
34 35 36 |
# File 'lib/foot_stats/resource.rb', line 34 def self.parse_response(response) raise NotImplementedError, "need to implement .parse_response in #{self}." end |
.resource_key ⇒ String
Return the resource key that is fetch from the API response.
50 51 52 |
# File 'lib/foot_stats/resource.rb', line 50 def self.resource_key raise NotImplementedError, "need to implement .resource_key in #{self}." end |
.resource_name ⇒ String
Return the resource name to request to FootStats.
42 43 44 |
# File 'lib/foot_stats/resource.rb', line 42 def self.resource_name raise NotImplementedError, "need to implement .resource_name in #{self}." end |
.updated_response(response, options) ⇒ Array
Return parsed response if updated when requested updated data
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/foot_stats/resource.rb', line 17 def self.updated_response(response, ) if [:updated] if response.updated? response.readed parse_response response else [] end else parse_response response end end |