Sha256: a5482854cfd96de8cdfc0dbc5d9640b8bf9ac506ef7b5de7a1f358777af96083
Contents?: true
Size: 841 Bytes
Versions: 7
Compression:
Stored size: 841 Bytes
Contents
require "colorized_string"; ColorizedString.colors; ColorizedString.modes; module PrivateMethods private; class << self def player_choice loop do print ColorizedString["Choose rock (r), paper (p) or scissors (s): "].colorize(:green); choice = gets.chomp.downcase; return Constants::NTRY_TO_SYM[choice] if Constants::NTRY_TO_SYM.key?(choice); puts ColorizedString["That entry is invalid. Please re-enter"].colorize(:green); 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
7 entries across 7 versions & 1 rubygems