class Testownik::HumanPlayer

Attributes

choice[R]

Public Instance Methods

ask_for_choice() click to toggle source
# File lib/testownik/HumanPlayer.rb, line 25
def ask_for_choice
  puts "Please call your selection by typing 
        'p' for paper, 's' for scissors or 'r' for rock"
  gets.chomp
end
get_decision() click to toggle source
# File lib/testownik/HumanPlayer.rb, line 6
def get_decision
  choice = ""
  loop do
    choice = ask_for_choice
    if validate_choice_format(choice) && !choice.empty?
      break
    end
  end
  choice
end
validate_choice_format(var_choice) click to toggle source
# File lib/testownik/HumanPlayer.rb, line 17
def validate_choice_format(var_choice)
  if var_choice.size == 1 && ("rps".include? var_choice)
    true
  else
    puts "You have entered incorrect letter. Please make correct selection."
  end
end