Sha256: 9f96ef0f18360b5a81e0fe0de8c456db2f0b09d8233e639e1ad0e1014b8ec4c1
Contents?: true
Size: 1.36 KB
Versions: 1
Compression:
Stored size: 1.36 KB
Contents
module FootStats class Player < Resource attribute_accessor :source_id, :full_name, :nickname def self.all(options={}) team_id = options.fetch(:team) request = Request.new self, :Equipe => team_id response = request.parse stream_key: "team_players-#{team_id}" return response.error if response.error? updated_response response, options end def self.parse_response(response) # FootStats sucks! # When there is only one player, resource isn't a collection, # but it's the only player! case response.resource when Hash [self.new( source_id: response.resource['@Id'].to_i, full_name: response.resource['@Nome'], nickname: response.resource['@Apelido'] )] when Array response.collect do |player_params| self.new( source_id: player_params['@Id'].to_i, full_name: player_params['@Nome'], nickname: player_params['@Apelido'] ) end else [] end end # Return the resource name to request to FootStats. # # @return [String] # def self.resource_name 'ListaJogadoresEquipe' end # Return the resource key that is fetch from the API response. # # @return [String] # def self.resource_key 'Jogador' end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
foot_stats-0.1.0 | lib/foot_stats/player.rb |