class FplGsheet::FixtureTeam

Public Class Methods

new(fixture,team_id) click to toggle source
# 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

Public Instance Methods

opp_score() click to toggle source
# File lib/fpl_gsheet/team.rb, line 39
def opp_score
  @venue=='H' ? @a_score : @h_score
end
opponent() click to toggle source
# 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_score() click to toggle source
# File lib/fpl_gsheet/team.rb, line 35
def own_score
  @venue=='H' ? @h_score : @a_score
end
result() click to toggle source
# 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