Class: FplGsheet::FixtureTeam

Inherits:
Object
  • Object
show all
Defined in:
lib/fpl_gsheet/team.rb

Instance Method Summary collapse

Constructor Details

#initialize(fixture, team_id) ⇒ FixtureTeam

Returns a new instance of FixtureTeam.



21
22
23
24
25
26
# File 'lib/fpl_gsheet/team.rb', line 21

def initialize(fixture,team_id)
  @fixture=fixture
  @venue = fixture.data['team_h']==team_id ? 'H' : 'A'
  @h_score = fixture.data['team_h_score']
  @a_score = fixture.data['team_a_score']
end

Instance Method Details

#opp_scoreObject



39
40
41
# File 'lib/fpl_gsheet/team.rb', line 39

def opp_score
  @venue=='H' ? @a_score : @h_score
end

#opponentObject



43
44
45
46
# File 'lib/fpl_gsheet/team.rb', line 43

def opponent
  id = @venue=='H' ? @fixture['team_a'] : @fixture['team_h']
  # How to get from this id to the Team object it represents?

end

#own_scoreObject



35
36
37
# File 'lib/fpl_gsheet/team.rb', line 35

def own_score
  @venue=='H' ? @h_score : @a_score
end

#resultObject



28
29
30
31
32
33
# File 'lib/fpl_gsheet/team.rb', line 28

def result
  return '-' if @h_score=='null'
  return 'D' if @h_score==@a_score
  winner = @h_score==@a_score ? 'H' : 'A'
  return @venue==winner ? 'W' : 'L'
end