Class: FootballApi::Match

Inherits:
BaseRequest show all
Includes:
Requestable
Defined in:
lib/football_api/match.rb

Constant Summary

Constants inherited from BaseRequest

BaseRequest::RETRIES

Constants included from Symbolizer

Symbolizer::HASH_OR_ARRAY_KEYS

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Requestable

included

Methods inherited from BaseRequest

action_query, get!, get_parameters, response

Methods included from Symbolizer

included

Constructor Details

#initialize(hash = {}) ⇒ Match

Returns a new instance of Match.



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/football_api/match.rb', line 39

def initialize(hash = {})
  @match_id                   = hash[:match_id]
  @static_id                  = hash[:match_static_id]
  @match_comp_id              = hash[:match_comp_id]
  @match_date                 = hash[:match_date]
  @match_formatted_date       = hash[:match_formatted_date]
  @match_status               = hash[:match_status]
  @match_time                 = hash[:match_time]
  @match_commentary_available = hash[:match_commentary_available]
  @match_localteam_id         = hash[:match_localteam_id]
  @match_localteam_name       = hash[:match_localteam_name]
  @match_localteam_score      = hash[:match_localteam_score]
  @match_visitorteam_id       = hash[:match_visitorteam_id]
  @match_visitorteam_name     = hash[:match_visitorteam_name]
  @match_visitorteam_score    = hash[:match_visitorteam_score]
  @match_ht_score             = hash[:match_ht_score]
  @match_ft_score             = hash[:match_ft_score]
  @match_et_score             = hash[:match_et_score]
  @match_season_beta          = hash[:match_season_beta]
  @match_week_beta            = hash[:match_week_beta]
  @match_venue_beta           = hash[:match_venue_beta]
  @match_venue_id_beta        = hash[:match_venue_id_beta]
  @match_venue_city_beta      = hash[:match_venue_city_beta]
  @match_events               = parse_match_events(hash[:match_events])
end

Class Attribute Details

.competition_idObject

Returns the value of attribute competition_id.



10
11
12
# File 'lib/football_api/match.rb', line 10

def competition_id
  @competition_id
end

Instance Attribute Details

#match_commentary_availableObject

Returns the value of attribute match_commentary_available.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_commentary_available
  @match_commentary_available
end

#match_comp_idObject

Returns the value of attribute match_comp_id.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_comp_id
  @match_comp_id
end

#match_dateObject

Returns the value of attribute match_date.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_date
  @match_date
end

#match_et_scoreObject

Returns the value of attribute match_et_score.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_et_score
  @match_et_score
end

#match_eventsObject

Returns the value of attribute match_events.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_events
  @match_events
end

#match_formatted_dateObject

Returns the value of attribute match_formatted_date.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_formatted_date
  @match_formatted_date
end

#match_ft_scoreObject

Returns the value of attribute match_ft_score.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_ft_score
  @match_ft_score
end

#match_ht_scoreObject

Returns the value of attribute match_ht_score.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_ht_score
  @match_ht_score
end

#match_idObject

Returns the value of attribute match_id.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_id
  @match_id
end

#match_localteam_idObject

Returns the value of attribute match_localteam_id.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_localteam_id
  @match_localteam_id
end

#match_localteam_nameObject

Returns the value of attribute match_localteam_name.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_localteam_name
  @match_localteam_name
end

#match_localteam_scoreObject

Returns the value of attribute match_localteam_score.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_localteam_score
  @match_localteam_score
end

#match_season_betaObject

Returns the value of attribute match_season_beta.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_season_beta
  @match_season_beta
end

#match_statusObject

Returns the value of attribute match_status.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_status
  @match_status
end

#match_timeObject

Returns the value of attribute match_time.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_time
  @match_time
end

#match_venue_betaObject

Returns the value of attribute match_venue_beta.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_venue_beta
  @match_venue_beta
end

#match_venue_city_betaObject

Returns the value of attribute match_venue_city_beta.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_venue_city_beta
  @match_venue_city_beta
end

#match_venue_id_betaObject

Returns the value of attribute match_venue_id_beta.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_venue_id_beta
  @match_venue_id_beta
end

#match_visitorteam_idObject

Returns the value of attribute match_visitorteam_id.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_visitorteam_id
  @match_visitorteam_id
end

#match_visitorteam_nameObject

Returns the value of attribute match_visitorteam_name.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_visitorteam_name
  @match_visitorteam_name
end

#match_visitorteam_scoreObject

Returns the value of attribute match_visitorteam_score.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_visitorteam_score
  @match_visitorteam_score
end

#match_week_betaObject

Returns the value of attribute match_week_beta.



28
29
30
# File 'lib/football_api/match.rb', line 28

def match_week_beta
  @match_week_beta
end

#static_idObject

Returns the value of attribute static_id.



28
29
30
# File 'lib/football_api/match.rb', line 28

def static_id
  @static_id
end

Class Method Details

.all_from_competition(competition) ⇒ Object



17
18
19
20
21
# File 'lib/football_api/match.rb', line 17

def all_from_competition(competition)
  @competition_id = competition.is_a?(Competition) ? competition.id : competition

  Array(response).map { |match| new(match) }
end

.match_paramsObject



23
24
25
# File 'lib/football_api/match.rb', line 23

def match_params
  self.competition_id ? { comp_id: self.competition_id} : {}
end

.todayObject



12
13
14
15
# File 'lib/football_api/match.rb', line 12

def today
  @competition_id = nil
  Array(response).map { |match| new(match) }
end

Instance Method Details

#parse_match_events(arr = []) ⇒ Object



65
66
67
# File 'lib/football_api/match.rb', line 65

def parse_match_events(arr = [])
  Array(arr).map { |e| FootballApi::Event.new(e) }
end