Class: FootballApi::MatchTeam

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hash = {}, key) ⇒ MatchTeam

Returns a new instance of MatchTeam.



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

def initialize(hash = {}, key)
  @id = hash[:comm_match_id]
  @players = parse_players(hash, key)
end

Instance Attribute Details

#idObject

Returns the value of attribute id.



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

def id
  @id
end

#playersObject

Returns the value of attribute players.



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

def players
  @players
end

Instance Method Details

#parse_players(hash = {}, key) ⇒ Object



11
12
13
14
15
16
17
18
19
20
# File 'lib/football_api/match_team.rb', line 11

def parse_players(hash = {}, key)
  players = []
  Array(hash[:comm_match_teams][key][:player]).each do |player|
    players << FootballApi::Player.new(player)
  end
  Array(hash[:comm_match_subs][key][:player]).each do |player|
    players << FootballApi::Player.new(player)
  end
  players
end