Class: Player

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/atpruby/player.rb

Instance Method Summary collapse

Instance Method Details

#h2h(opponent) ⇒ Object



17
18
19
20
21
22
# File 'lib/atpruby/player.rb', line 17

def h2h opponent
  return if opponent.nil?
  w = wins.where(loser_id:opponent.player_id).count
  l = losses.where(winner_id:opponent.player_id).count
  "#{w}-#{l}"
end

#h2h_details(opponent) ⇒ Object



24
25
26
27
28
29
# File 'lib/atpruby/player.rb', line 24

def h2h_details opponent
  return if opponent.nil?
  w = wins.where(loser_id:opponent.player_id)
  l = losses.where(winner_id:opponent.player_id)
  w.union(l)
end

#matchesObject



13
14
15
# File 'lib/atpruby/player.rb', line 13

def matches
  wins.union(losses)
end

#nameObject



9
10
11
# File 'lib/atpruby/player.rb', line 9

def name
  [self.firstname, self.lastname].join(' ')
end

#slam_finalsObject



35
36
37
38
39
# File 'lib/atpruby/player.rb', line 35

def slam_finals
  w = wins.where(tourney_level:'G',round:'F')
  l = losses.where(tourney_level:'G',round:'F')
  w.union(l)
end

#slamsObject



31
32
33
# File 'lib/atpruby/player.rb', line 31

def slams
  wins.where(tourney_level:'G',round:'F')
end