Class: OXO::Human
- Inherits:
-
Object
- Object
- OXO::Human
- Defined in:
- lib/oxo/human.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
readonly
Returns the value of attribute color.
Instance Method Summary collapse
-
#initialize(color) ⇒ Human
constructor
A new instance of Human.
- #make_move(board) ⇒ Object
- #name ⇒ Object
Constructor Details
#initialize(color) ⇒ Human
Returns a new instance of Human.
8 9 10 |
# File 'lib/oxo/human.rb', line 8 def initialize(color) @color = color end |
Instance Attribute Details
#color ⇒ Object (readonly)
Returns the value of attribute color.
6 7 8 |
# File 'lib/oxo/human.rb', line 6 def color @color end |
Instance Method Details
#make_move(board) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/oxo/human.rb', line 16 def make_move(board) move = :illegal while move == :illegal print "Your move (1...9, 0/q=quit)? " answer = gets.chomp move = parse_answer(answer, board) puts "Illegal move: #{answer}" if move == :illegal end move end |
#name ⇒ Object
12 13 14 |
# File 'lib/oxo/human.rb', line 12 def name "Human" end |