Class: Infostrada::Match
- Inherits:
-
BaseRequest
- Object
- BaseRequest
- Infostrada::Match
- Extended by:
- Forwardable
- Defined in:
- lib/infostrada/match.rb
Overview
You can get the information about a single game, about all games in an edition or about all games in a day.
Examples:
Infostrada::Match.where(edition_id: 2398) # all matches for edition 2398
Infostrada::Match.where(date: Time.now) # all matches for current date (live info)
Infostrada::Match.where(date: Date.today+1.day) # all matches for tomorrow (live info)
Infostrada::Match.where(id: 1337) # information about the match 1337
Constant Summary collapse
- URLS =
We can get all matches for a given edition (very heavy payload). Or we can just get the match information on a single match.
{ list: '/GetMatchList_Edition', single: '/GetMatchInfo', live_list: '/GetMatchLiveList_Date' }
Constants inherited from BaseRequest
Instance Attribute Summary collapse
-
#aggregate_winner_id ⇒ Object
Returns the value of attribute aggregate_winner_id.
-
#awarded ⇒ Object
Returns the value of attribute awarded.
-
#away_team ⇒ Object
Returns the value of attribute away_team.
-
#current_period_started_at ⇒ Object
Returns the value of attribute current_period_started_at.
-
#date ⇒ Object
Returns the value of attribute date.
-
#edition ⇒ Object
Returns the value of attribute edition.
-
#finished ⇒ Object
Returns the value of attribute finished.
-
#first_leg_score ⇒ Object
Returns the value of attribute first_leg_score.
-
#goals ⇒ Object
Returns the value of attribute goals.
-
#home_team ⇒ Object
Returns the value of attribute home_team.
-
#id ⇒ Object
Returns the value of attribute id.
-
#knockout_phase ⇒ Object
Returns the value of attribute knockout_phase.
-
#leg ⇒ Object
Returns the value of attribute leg.
-
#lineup_official ⇒ Object
Lineup.
-
#lineup_provisional ⇒ Object
Lineup.
-
#live ⇒ Object
Check if the live score, live goals and live lineups are already available.
-
#live_goals ⇒ Object
Check if the live score, live goals and live lineups are already available.
-
#live_lineup ⇒ Object
Check if the live score, live goals and live lineups are already available.
-
#live_score ⇒ Object
Check if the live score, live goals and live lineups are already available.
-
#match_status ⇒ Object
Returns the value of attribute match_status.
-
#period ⇒ Object
period is taken from Infostradas n_PeriodSort, that can have one of these values:.
-
#phase ⇒ Object
Returns the value of attribute phase.
-
#postponed ⇒ Object
Returns the value of attribute postponed.
-
#referee ⇒ Object
Returns the value of attribute referee.
-
#rescheduled ⇒ Object
Returns the value of attribute rescheduled.
-
#round ⇒ Object
Returns the value of attribute round.
-
#spectators ⇒ Object
Returns the value of attribute spectators.
-
#stadium_id ⇒ Object
Returns the value of attribute stadium_id.
-
#stadium_name ⇒ Object
Returns the value of attribute stadium_name.
-
#started ⇒ Object
Returns the value of attribute started.
-
#started_at ⇒ Object
Returns the value of attribute started_at.
-
#status ⇒ Object
Returns the value of attribute status.
-
#status_code ⇒ Object
status_code is taken from Infostradas n_MatchStatusCode, that can have on of these values:.
-
#status_short ⇒ Object
Returns the value of attribute status_short.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(hash) ⇒ Match
constructor
A new instance of Match.
- #live_event_list ⇒ Object
- #live_goals? ⇒ Boolean
- #live_lineup? ⇒ Boolean
- #live_score? ⇒ Boolean
Methods inherited from BaseRequest
Constructor Details
#initialize(hash) ⇒ Match
Returns a new instance of Match.
100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/infostrada/match.rb', line 100 def initialize(hash) @id = hash['n_MatchID'] @date = Formatter.format_date(hash['d_DateUTC']) @rescheduled = hash['b_RescheduledToBeResumed'] @round = hash['n_RoundNr'] @aggregate_winner_id = hash['n_WinnerOnAggregateTeamID'] @current_period_started_at = Formatter.format_date(hash['d_CurrentPeriodStartTime']) @status_code = hash['n_MatchStatusCode'] @status = hash['c_MatchStatus'] @status_short = hash['c_MatchStatusShort'] @leg = hash['n_Leg'] @started_at = Formatter.format_date(hash['d_MatchStartTime']) @stadium_id = hash['n_StadiumGeoID'] @stadium_name = hash['c_Stadium'] @spectators = hash['n_Spectators'] @live = hash['b_Live'] @started = hash['b_Started'] @finished = hash['b_Finished'] @awarded = hash['b_Awarded'] @live_score = hash['b_DataEntryLiveScore'] @live_goals = hash['b_DataEntryLiveGoal'] @live_lineup = hash['b_DataEntryLiveLineup'] @lineup_provisional = hash['b_LineupProvisional'] @lineup_official = hash['b_LineupOfficial'] @period = hash['n_PeriodSort'] @referee = Referee.new(hash) @phase = Phase.new(hash) @home_team = Team.new(hash, 'home') @away_team = Team.new(hash, 'away') @goals = Goals.new(hash) @edition = Edition.new(hash) self end |
Instance Attribute Details
#aggregate_winner_id ⇒ Object
Returns the value of attribute aggregate_winner_id.
20 21 22 |
# File 'lib/infostrada/match.rb', line 20 def aggregate_winner_id @aggregate_winner_id end |
#awarded ⇒ Object
Returns the value of attribute awarded.
18 19 20 |
# File 'lib/infostrada/match.rb', line 18 def awarded @awarded end |
#away_team ⇒ Object
Returns the value of attribute away_team.
17 18 19 |
# File 'lib/infostrada/match.rb', line 17 def away_team @away_team end |
#current_period_started_at ⇒ Object
Returns the value of attribute current_period_started_at.
20 21 22 |
# File 'lib/infostrada/match.rb', line 20 def current_period_started_at @current_period_started_at end |
#date ⇒ Object
Returns the value of attribute date.
17 18 19 |
# File 'lib/infostrada/match.rb', line 17 def date @date end |
#edition ⇒ Object
Returns the value of attribute edition.
21 22 23 |
# File 'lib/infostrada/match.rb', line 21 def edition @edition end |
#finished ⇒ Object
Returns the value of attribute finished.
18 19 20 |
# File 'lib/infostrada/match.rb', line 18 def finished @finished end |
#first_leg_score ⇒ Object
Returns the value of attribute first_leg_score.
19 20 21 |
# File 'lib/infostrada/match.rb', line 19 def first_leg_score @first_leg_score end |
#goals ⇒ Object
Returns the value of attribute goals.
18 19 20 |
# File 'lib/infostrada/match.rb', line 18 def goals @goals end |
#home_team ⇒ Object
Returns the value of attribute home_team.
17 18 19 |
# File 'lib/infostrada/match.rb', line 17 def home_team @home_team end |
#id ⇒ Object
Returns the value of attribute id.
17 18 19 |
# File 'lib/infostrada/match.rb', line 17 def id @id end |
#knockout_phase ⇒ Object
Returns the value of attribute knockout_phase.
19 20 21 |
# File 'lib/infostrada/match.rb', line 19 def knockout_phase @knockout_phase end |
#leg ⇒ Object
Returns the value of attribute leg.
19 20 21 |
# File 'lib/infostrada/match.rb', line 19 def leg @leg end |
#lineup_official ⇒ Object
Lineup
27 28 29 |
# File 'lib/infostrada/match.rb', line 27 def lineup_official @lineup_official end |
#lineup_provisional ⇒ Object
Lineup
27 28 29 |
# File 'lib/infostrada/match.rb', line 27 def lineup_provisional @lineup_provisional end |
#live ⇒ Object
Check if the live score, live goals and live lineups are already available
24 25 26 |
# File 'lib/infostrada/match.rb', line 24 def live @live end |
#live_goals ⇒ Object
Check if the live score, live goals and live lineups are already available
24 25 26 |
# File 'lib/infostrada/match.rb', line 24 def live_goals @live_goals end |
#live_lineup ⇒ Object
Check if the live score, live goals and live lineups are already available
24 25 26 |
# File 'lib/infostrada/match.rb', line 24 def live_lineup @live_lineup end |
#live_score ⇒ Object
Check if the live score, live goals and live lineups are already available
24 25 26 |
# File 'lib/infostrada/match.rb', line 24 def live_score @live_score end |
#match_status ⇒ Object
Returns the value of attribute match_status.
18 19 20 |
# File 'lib/infostrada/match.rb', line 18 def match_status @match_status end |
#period ⇒ Object
period is taken from Infostradas n_PeriodSort, that can have one of these values:
1 = Not started 2 = 1st Half 3 = Halftime 4 = 2nd Half 5 = 90 mins 6 = 1st Extra Time 7 = 105 mins 8 = 2nd Extra Time 9 = 120 mins 10 = Penalty Shootout 11 = End
42 43 44 |
# File 'lib/infostrada/match.rb', line 42 def period @period end |
#phase ⇒ Object
Returns the value of attribute phase.
17 18 19 |
# File 'lib/infostrada/match.rb', line 17 def phase @phase end |
#postponed ⇒ Object
Returns the value of attribute postponed.
19 20 21 |
# File 'lib/infostrada/match.rb', line 19 def postponed @postponed end |
#referee ⇒ Object
Returns the value of attribute referee.
19 20 21 |
# File 'lib/infostrada/match.rb', line 19 def referee @referee end |
#rescheduled ⇒ Object
Returns the value of attribute rescheduled.
17 18 19 |
# File 'lib/infostrada/match.rb', line 17 def rescheduled @rescheduled end |
#round ⇒ Object
Returns the value of attribute round.
17 18 19 |
# File 'lib/infostrada/match.rb', line 17 def round @round end |
#spectators ⇒ Object
Returns the value of attribute spectators.
19 20 21 |
# File 'lib/infostrada/match.rb', line 19 def spectators @spectators end |
#stadium_id ⇒ Object
Returns the value of attribute stadium_id.
18 19 20 |
# File 'lib/infostrada/match.rb', line 18 def stadium_id @stadium_id end |
#stadium_name ⇒ Object
Returns the value of attribute stadium_name.
18 19 20 |
# File 'lib/infostrada/match.rb', line 18 def stadium_name @stadium_name end |
#started ⇒ Object
Returns the value of attribute started.
20 21 22 |
# File 'lib/infostrada/match.rb', line 20 def started @started end |
#started_at ⇒ Object
Returns the value of attribute started_at.
20 21 22 |
# File 'lib/infostrada/match.rb', line 20 def started_at @started_at end |
#status ⇒ Object
Returns the value of attribute status.
20 21 22 |
# File 'lib/infostrada/match.rb', line 20 def status @status end |
#status_code ⇒ Object
status_code is taken from Infostradas n_MatchStatusCode, that can have on of these values:
2 = Line-up 4 = Not Started 8 = In Progress 16 = Interval 32 = Suspended (during the match) 128 = Finished (official result) 192 = Finished (unofficial result). This is a combination of code 64 and 128. 512 = Abandoned 1024 = Postponed 2048 = Delayed
If a match is stopped temporarily, n_MatchStatusCode is set to 32 (=Suspended). If it becomes clear that the match, after being suspended, will not be restarted on the same day, n_MatchStatusCode is set to 512 (=Abandoned).
60 61 62 |
# File 'lib/infostrada/match.rb', line 60 def status_code @status_code end |
#status_short ⇒ Object
Returns the value of attribute status_short.
17 18 19 |
# File 'lib/infostrada/match.rb', line 17 def status_short @status_short end |
Class Method Details
.get_match_list(options) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/infostrada/match.rb', line 87 def self.get_match_list() edition_id = .delete(:edition_id) match_id = .delete(:id) date = .delete(:date) date = date.strftime('%Y%m%d') if date list = get!(URLS[:list], query: { editionid: edition_id.to_i }) if edition_id list = get!(URLS[:single], query: { matchid: match_id.to_i }) if match_id list = get!(URLS[:live_list], query: { date: date }) if date list end |
.where(options = {}) ⇒ Object
76 77 78 79 80 81 82 83 84 85 |
# File 'lib/infostrada/match.rb', line 76 def self.where( = {}) list = get_match_list() matches = [] list.each do |match_hash| matches << Match.new(match_hash) end matches.size > 1 ? matches : matches.first end |
Instance Method Details
#live_event_list ⇒ Object
157 158 159 |
# File 'lib/infostrada/match.rb', line 157 def live_event_list event_list = MatchEventList.where(match_id: self.id) end |
#live_goals? ⇒ Boolean
149 150 151 |
# File 'lib/infostrada/match.rb', line 149 def live_goals? @live_goals || false end |
#live_lineup? ⇒ Boolean
153 154 155 |
# File 'lib/infostrada/match.rb', line 153 def live_lineup? @live_lineup || false end |
#live_score? ⇒ Boolean
145 146 147 |
# File 'lib/infostrada/match.rb', line 145 def live_score? @live_score || false end |