module PrivateMethods
add module for private methods for the rpsg calculations
Public Class Methods
final_outcome(pl,co)
click to toggle source
define final outcome that gives the result of who one the whole match
# File lib/PrivateMethods.rb, line 26 def final_outcome(pl,co) return :WIN if pl > co return :LOSE if pl < co return :TIE if pl = co # there will never be a tie for the final outcome due to the code in the play() method end
player_choice()
click to toggle source
make a definition that asks for the players choice
# File lib/PrivateMethods.rb, line 6 def player_choice loop do print "\nChoose: Rock (r), Paper (p), or Scissors (s): " choice = gets.chomp.downcase if Constants::NTRY_TO_SYM.key?(choice) return Constants::NTRY_TO_SYM[choice] elsif choice != Constants::VALID_ENTRIES puts "\nThat entry is invalid. Please re-enter.\n" else return nil end end end
player_outcome(plays)
click to toggle source
define outcomes of players choice against cpu
# File lib/PrivateMethods.rb, line 20 def player_outcome(plays) return :WIN if Constants::WINNERS.include?(plays) return :LOSE if Constants::LOSERS.include?(plays) return :TIE if !:WIN | !:LOSE end