module Bagel::Tennis::Scoring

Constants

ADVANTAGE
FIFTEEN
FORTY
FORTY_BLANK
LOVE
THIRTY

Public Class Methods

point_call(player, opponent, tiebreak=false) click to toggle source
# 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