Class: FootStats::Championship
- Defined in:
- lib/foot_stats/championship.rb
Class Method Summary collapse
-
.all(options = {}) ⇒ Array
Retrieve all championships from FootStats.
- .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
-
#classification(options = {}) ⇒ Array
Return the Championship classification.
-
#matches(options = {}) ⇒ Array
Return all the Championship matches.
-
#teams(options = {}) ⇒ Array
Return the Championship teams.
Methods inherited from Resource
Methods included from AttributeAccessor
Constructor Details
This class inherits a constructor from FootStats::Resource
Class Method Details
.all(options = {}) ⇒ Array
Retrieve all championships from FootStats
9 10 11 12 13 14 15 |
# File 'lib/foot_stats/championship.rb', line 9 def self.all( = {}) response = Request.new(self).parse stream_key: 'championships' return response.error if response.error? updated_response response, end |
.parse_response(response) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/foot_stats/championship.rb', line 17 def self.parse_response(response) response.collect do |championship| new( :source_id => championship['@Id'].to_i, :name => championship['@Nome'], :has_classification => championship['@TemClassificacao'] == 'True', :current_round => championship['@RodadaATual'].to_i, :total_rounds => championship['@Rodadas'].to_i ) end end |
.resource_key ⇒ String
Return the resource key that is fetch from the API response.
41 42 43 |
# File 'lib/foot_stats/championship.rb', line 41 def self.resource_key 'Campeonato' end |
.resource_name ⇒ String
Return the resource name to request to FootStats.
33 34 35 |
# File 'lib/foot_stats/championship.rb', line 33 def self.resource_name 'ListaCampeonatos' end |
Instance Method Details
#classification(options = {}) ⇒ Array
Return the Championship classification.
49 50 51 |
# File 'lib/foot_stats/championship.rb', line 49 def classification( = {}) ChampionshipClassification.all(.merge(championship: source_id)) end |