Class: MineSweeper::Turn

Inherits:
Object
  • Object
show all
Defined in:
lib/mine-sweeper/turn.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeTurn



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/mine-sweeper/turn.rb', line 7

def initialize
  print "which row?\n > "
  @row = gets.chomp.to_i
  print "which column?\n > "
  @column = gets.chomp.to_i
  @action = "x"
  until action_is_valid?
    print "which action?\n > "
    @action = gets.chomp.upcase
    print "that is not a valid action" unless action_is_valid?
  end
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



5
6
7
# File 'lib/mine-sweeper/turn.rb', line 5

def action
  @action
end

Instance Method Details

#messageObject



20
21
22
23
24
# File 'lib/mine-sweeper/turn.rb', line 20

def message
  { row: @row,
    column: @column,
    action: @action }
end