Class: FootStats::ChampionshipClassification

Inherits:
Resource
  • Object
show all
Defined in:
lib/foot_stats/championship_classification.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Methods inherited from Resource

#initialize, updated_response

Methods included from AttributeAccessor

#attributes, included

Constructor Details

This class inherits a constructor from FootStats::Resource

Instance Attribute Details

#drawsObject

Returns the value of attribute draws.



3
4
5
# File 'lib/foot_stats/championship_classification.rb', line 3

def draws
  @draws
end

#gamesObject

Returns the value of attribute games.



3
4
5
# File 'lib/foot_stats/championship_classification.rb', line 3

def games
  @games
end

#goals_againstObject

Returns the value of attribute goals_against.



4
5
6
# File 'lib/foot_stats/championship_classification.rb', line 4

def goals_against
  @goals_against
end

#goals_balanceObject

Returns the value of attribute goals_balance.



4
5
6
# File 'lib/foot_stats/championship_classification.rb', line 4

def goals_balance
  @goals_balance
end

#goals_forObject

Returns the value of attribute goals_for.



4
5
6
# File 'lib/foot_stats/championship_classification.rb', line 4

def goals_for
  @goals_for
end

#groupObject

Returns the value of attribute group.



3
4
5
# File 'lib/foot_stats/championship_classification.rb', line 3

def group
  @group
end

#home_defeatsObject

Returns the value of attribute home_defeats.



5
6
7
# File 'lib/foot_stats/championship_classification.rb', line 5

def home_defeats
  @home_defeats
end

#home_drawsObject

Returns the value of attribute home_draws.



5
6
7
# File 'lib/foot_stats/championship_classification.rb', line 5

def home_draws
  @home_draws
end

#home_victoriesObject

Returns the value of attribute home_victories.



4
5
6
# File 'lib/foot_stats/championship_classification.rb', line 4

def home_victories
  @home_victories
end

#lossObject

Returns the value of attribute loss.



3
4
5
# File 'lib/foot_stats/championship_classification.rb', line 3

def loss
  @loss
end

#max_pointObject

Returns the value of attribute max_point.



5
6
7
# File 'lib/foot_stats/championship_classification.rb', line 5

def max_point
  @max_point
end

#outside_defeatsObject

Returns the value of attribute outside_defeats.



5
6
7
# File 'lib/foot_stats/championship_classification.rb', line 5

def outside_defeats
  @outside_defeats
end

#outside_drawsObject

Returns the value of attribute outside_draws.



5
6
7
# File 'lib/foot_stats/championship_classification.rb', line 5

def outside_draws
  @outside_draws
end

#outside_victoriesObject

Returns the value of attribute outside_victories.



4
5
6
# File 'lib/foot_stats/championship_classification.rb', line 4

def outside_victories
  @outside_victories
end

#pointsObject

Returns the value of attribute points.



3
4
5
# File 'lib/foot_stats/championship_classification.rb', line 3

def points
  @points
end

#positionObject

Returns the value of attribute position.



3
4
5
# File 'lib/foot_stats/championship_classification.rb', line 3

def position
  @position
end

#team_source_idObject

Returns the value of attribute team_source_id.



3
4
5
# File 'lib/foot_stats/championship_classification.rb', line 3

def team_source_id
  @team_source_id
end

#useObject

Returns the value of attribute use.



6
7
8
# File 'lib/foot_stats/championship_classification.rb', line 6

def use
  @use
end

#victoriesObject

Returns the value of attribute victories.



3
4
5
# File 'lib/foot_stats/championship_classification.rb', line 3

def victories
  @victories
end

Class Method Details

.all(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
# File 'lib/foot_stats/championship_classification.rb', line 8

def self.all(options={})
  championship_id = options.fetch(:championship)
  request  = Request.new self, :Campeonato => championship_id
  response = request.parse stream_key: "championship-classification-#{championship_id}"

  return response.error if response.error?

  updated_response response, options
end

.parse_response(response) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/foot_stats/championship_classification.rb', line 18

def self.parse_response(response)
  response["Classificacoes"]['Classificacao']['Equipe'].collect do |classification|
    ChampionshipClassification.new(
      :team_source_id    => classification['@Id'].to_i,
      :group             => classification['@Grupo'],
      :position          => classification['Posicao'],
      :points            => classification['Pontos_Ganhos'],
      :games             => classification['Jogos'],
      :victories         => classification['Vitorias'],
      :draws             => classification['Empates'],
      :loss              => classification['Derrotas'],
      :goals_for         => classification['Gols_Pro'],
      :goals_against     => classification['Gols_Contra'],
      :goals_balance     => classification['Saldo_Gols'],
      :home_victories    => classification['Vitorias_Casa'],
      :outside_victories => classification['Vitorias_Fora'],
      :home_draws        => classification['Empates_Casa'],
      :outside_draws     => classification['Empate_Fora'],
      :home_defeats      => classification['Derrotas_Casa'],
      :outside_defeats   => classification['Derrotas_Fora'],
      :max_point         => classification['Ponto_Maximo'],
      :use               => classification['Aproveitamento']
    )
  end
end

.resource_keyString

Return the resource key that is fetch from the API response.

Returns:

  • (String)


56
57
58
# File 'lib/foot_stats/championship_classification.rb', line 56

def self.resource_key
  'Campeonato'
end

.resource_nameString

Return the resource name to request to FootStats.

Returns:

  • (String)


48
49
50
# File 'lib/foot_stats/championship_classification.rb', line 48

def self.resource_name
  'ListaClassificacao'
end