Sha256: 066f6883d730ac94446f5cccded77883d7a0c59f4b41f62ba593bb7e49944a55

Contents?: true

Size: 685 Bytes

Versions: 2

Compression:

Stored size: 685 Bytes

Contents

private;
module PrivateVars
  class << self
    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; 
    def player_outcome(plays)
      return :WIN  if Constants::WINNERS.include?(plays);
      return :LOSE if Constants::LOSERS.include?(plays);
      return :TIE  if !:WIN | !:LOSE;
    end; 
    def final_outcome(pl, co) 
      return :WIN  if pl > co; 
      return :LOSE if pl < co;
      return :TIE  if pl = co; 
    end; 
  end;
end;

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
PlayRockPaperScissorsGame-1.4.4 lib/ref/PrivateVars.rb
PlayRockPaperScissorsGame-1.4.3 lib/ref/PrivateVars.rb