class Bagel::Tennis::Outcome

Constants

BACKHAND
FORCED_ERROR
FOREHAND
SERVE
UNFORCED_ERROR
WINNER

Public Class Methods

new(winner:, reason:, shot:, net: nil) click to toggle source
# File lib/bagel/tennis/outcome.rb, line 13
def initialize(winner:, reason:, shot:, net: nil)
  @winner = winner
  @reason = reason
  @shot = shot
  @net = net
end

Public Instance Methods

ace?() click to toggle source
# File lib/bagel/tennis/outcome.rb, line 20
def ace?
  winner? && shot == SERVE
end
p1_net_point?() click to toggle source
# File lib/bagel/tennis/outcome.rb, line 40
def p1_net_point?
  net && !net[Player.index(Player.ONE)].nil?
end
p1_won?() click to toggle source
# File lib/bagel/tennis/outcome.rb, line 32
def p1_won?
  winner == Player.ONE
end
p2_net_point?() click to toggle source
# File lib/bagel/tennis/outcome.rb, line 44
def p2_net_point?
  net && !net[Player.index(Player.TWO)].nil?
end
p2_won?() click to toggle source
# File lib/bagel/tennis/outcome.rb, line 36
def p2_won?
  winner == Player.TWO
end
unforced_error?() click to toggle source
# File lib/bagel/tennis/outcome.rb, line 28
def unforced_error?
  reason == UNFORCED_ERROR
end
winner?() click to toggle source
# File lib/bagel/tennis/outcome.rb, line 24
def winner?
  reason == WINNER
end