Class: FootStats::Team
Class Method Summary collapse
- .all(options = {}) ⇒ Object
- .parse_response(response) ⇒ Object
-
.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.
Instance Method Summary collapse
-
#players(options = {}) ⇒ Array
Return all possible team players.
Methods inherited from Resource
Methods included from AttributeAccessor
Constructor Details
This class inherits a constructor from FootStats::Resource
Class Method Details
.all(options = {}) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/foot_stats/team.rb', line 13 def self.all(={}) championship_id = .fetch(:championship) request = Request.new self, :IdCampeonato => .fetch(:championship) response = request.parse stream_key: "team-championship-#{championship_id}" return response.error if response.error? updated_response response, end |
.parse_response(response) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/foot_stats/team.rb', line 23 def self.parse_response(response) response.collect do |team| Team.new( :source_id => team['@Id'].to_i, :full_name => team['@Nome'], :city => team['@Cidade'], :country => team['@Pais'] ) end end |
.resource_key ⇒ String
Return the resource key that is fetch from the API response.
46 47 48 |
# File 'lib/foot_stats/team.rb', line 46 def self.resource_key 'Equipe' end |
.resource_name ⇒ String
Return the resource name to request to FootStats.
38 39 40 |
# File 'lib/foot_stats/team.rb', line 38 def self.resource_name 'ListaEquipesCampeonato' end |