Class: FootballApi::MatchSubstitutions

Inherits:
Object
  • Object
show all
Defined in:
lib/football_api/match_substitutions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}) ⇒ MatchSubstitutions

Returns a new instance of MatchSubstitutions.



6
7
8
9
10
# File 'lib/football_api/match_substitutions.rb', line 6

def initialize(hash = {})
  @match_id     = hash[:match_id]
  @local_team   = subs(hash, :localteam)
  @visitor_team = subs(hash, :visitorteam)
end

Instance Attribute Details

#local_teamObject

Returns the value of attribute local_team.



4
5
6
# File 'lib/football_api/match_substitutions.rb', line 4

def local_team
  @local_team
end

#match_idObject

Returns the value of attribute match_id.



4
5
6
# File 'lib/football_api/match_substitutions.rb', line 4

def match_id
  @match_id
end

#visitor_teamObject

Returns the value of attribute visitor_team.



4
5
6
# File 'lib/football_api/match_substitutions.rb', line 4

def visitor_team
  @visitor_team
end

Instance Method Details

#subs(hash, key) ⇒ Object



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

def subs(hash, key)
  return [] unless hash[key]
  Array(hash[key][:substitution]).map { |s| Substitution.new(s) }
end