Module: Master::RPS::RockPaperScissors::PrivateVars

Defined in:
lib/rps.rb

Class Method Summary collapse

Class Method Details

.final_outcome(pl, co) ⇒ Object



105
106
107
108
109
# File 'lib/rps.rb', line 105

def final_outcome(pl, co) 
  return :WIN  if pl > co; 
  return :LOSE if pl < co;
  return :TIE  if pl = co; 
end

.player_choice ⇒ Object



92
93
94
95
96
97
98
99
# File 'lib/rps.rb', line 92

def player_choice
  loop do
    print "Choose rock (r), paper (p) or scissors (s): ";
    choice = gets.chomp.downcase;
    return Constants::NTRY_TO_SYM[choice] if Constants::NTRY_TO_SYM.key?(choice); 
    puts "That entry is invalid. Please re-enter"; 
  end; 
end

.player_outcome(plays) ⇒ Object



100
101
102
103
104
# File 'lib/rps.rb', line 100

def player_outcome(plays)
  return :WIN  if Constants::WINNERS.include?(plays);
  return :LOSE if Constants::LOSERS.include?(plays);
  return :TIE  if (!:WIN || !:LOSE);
end