Module: Bagel::Tennis::Scoring

Defined in:
lib/bagel/tennis/scoring.rb

Constant Summary collapse

LOVE =
'0'
FIFTEEN =
'15'
THIRTY =
'30'
FORTY =
'40'
FORTY_BLANK =
''
ADVANTAGE =
'A'

Class Method Summary collapse

Class Method Details

.point_call(player, opponent, tiebreak = false) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/bagel/tennis/scoring.rb', line 10

def self.point_call(player, opponent, tiebreak=false)
  return player.to_s if tiebreak

  return LOVE if player == 0
  return FIFTEEN if player == 1
  return THIRTY if player == 2

  if opponent < 3 || player == opponent
    FORTY
  elsif player < opponent
    FORTY_BLANK
  else
    ADVANTAGE
  end
end