Class: Player
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Player
- Defined in:
- lib/atpruby/player.rb
Instance Method Summary collapse
- #h2h(opponent) ⇒ Object
- #h2h_details(opponent) ⇒ Object
- #matches ⇒ Object
- #name ⇒ Object
- #slam_finals ⇒ Object
- #slams ⇒ Object
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 |
#matches ⇒ Object
13 14 15 |
# File 'lib/atpruby/player.rb', line 13 def matches wins.union(losses) end |
#name ⇒ Object
9 10 11 |
# File 'lib/atpruby/player.rb', line 9 def name [self.firstname, self.lastname].join(' ') end |
#slam_finals ⇒ Object
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 |
#slams ⇒ Object
31 32 33 |
# File 'lib/atpruby/player.rb', line 31 def slams wins.where(tourney_level:'G',round:'F') end |