class RpsGameDavidxin::Player

Public Class Methods

new(name) click to toggle source
# File lib/rps_game_davidxin.rb, line 92
def initialize(name)
  @name = name
end

Public Instance Methods

is_input_valid?(input) click to toggle source
# File lib/rps_game_davidxin.rb, line 107
def is_input_valid?(input)
  ["r", "p", "s"].include?(input)
end
turn() click to toggle source
# File lib/rps_game_davidxin.rb, line 96
def turn
  is_valid = false
  until is_valid
    print "#{@name} - Enter your move ([R]ock, [P]aper, or [S]cissors): "
    input = gets.chomp.downcase
    is_valid = is_input_valid?(input)
    puts "Please enter 'r' 'p' or 's' to play" unless is_valid
  end
  return input
end