Class: FootStats::Match
Direct Known Subclasses
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
-
#live(options = {}) ⇒ Live
Return live date of a match.
-
#live=(value) ⇒ boolean
Live setter.
-
#live? ⇒ boolean
Checks if match has live coverage.
-
#narrations(options = {}) ⇒ Array
Return the narration from a match.
Methods inherited from Resource
Methods included from AttributeAccessor
Constructor Details
This class inherits a constructor from FootStats::Resource
Class Method Details
.all(options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/foot_stats/match.rb', line 9 def self.all(={}) championship_id = .fetch(:championship) request = Request.new self, :Campeonato => .fetch(:championship) response = request.parse stream_key: "match_championship-#{championship_id}" return response.error if response.error? updated_response response, end |
.parse_response(response) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/foot_stats/match.rb', line 19 def self.parse_response(response) response['Partida'].collect do |match| match_object = Match.new( :source_id => match['@Id'].to_i, :date => match['Data'], :status => match['Status'], :referee => match['Arbitro'], :stadium => match['Estadio'], :city => match['Cidade'], :state => match['Estado'], :country => match['Pais'], :has_statistic => match['TemEstatistica'], # TODO: Need to see boolean :has_narration => match['TemNarracao'], # fields. :round => match['Rodada'], :phase => match['Fase'], :cup => match['Taca'], :group => match['Grupo'], :game_number => match['NumeroJogo'], :live => match['AoVivo'] ) match['Equipe'].each do |team| if team['@Tipo'] == 'Mandante' match_object.home_team = team['@Id'].to_i match_object.home_team_name = team['@Nome'] match_object.home_score = team['@Placar'] match_object.home_penalties_score = team['@PlacarPenaltis'] else match_object.visitor_team = team['@Id'].to_i match_object.visitor_team_name = team['@Nome'] match_object.visitor_score = team['@Placar'] match_object.visitor_penalties_score = team['@PlacarPenaltis'] end end match_object end end |
.resource_key ⇒ String
Return the resource key that is fetch from the API response.
70 71 72 |
# File 'lib/foot_stats/match.rb', line 70 def self.resource_key 'Partidas' end |
.resource_name ⇒ String
Return the resource name to request to FootStats.
62 63 64 |
# File 'lib/foot_stats/match.rb', line 62 def self.resource_name 'ListaPartidas' end |
Instance Method Details
#live(options = {}) ⇒ Live
Return live date of a match
86 87 88 |
# File 'lib/foot_stats/match.rb', line 86 def live( = {}) Live.find source_id, end |
#live=(value) ⇒ boolean
Live setter
94 95 96 97 98 99 100 |
# File 'lib/foot_stats/match.rb', line 94 def live=(value) if value == 'Sim' || value == true @has_live = true else @has_live = false end end |
#live? ⇒ boolean
Checks if match has live coverage
106 107 108 |
# File 'lib/foot_stats/match.rb', line 106 def live? @has_live end |