Class: RockPaperScissors::Human

Inherits:
Player
  • Object
show all
Defined in:
lib/rock_paper_scissors/human.rb

Instance Attribute Summary

Attributes inherited from Player

#name

Instance Method Summary collapse

Constructor Details

#initialize(board, player_number) ⇒ Human

Returns a new instance of Human.



7
8
9
10
# File 'lib/rock_paper_scissors/human.rb', line 7

def initialize(board, player_number)
  super(board, player_number)
  @name = get_name
end

Instance Method Details

#select_moveObject



12
13
14
15
16
17
18
19
# File 'lib/rock_paper_scissors/human.rb', line 12

def select_move
  loop do
    move = ask_move
    if valid_format?(move)
      break if @board.place_move(@player_number, move)
    end
  end
end