class MineSweeper::Turn
Attributes
action[R]
Public Class Methods
new()
click to toggle source
# 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
Public Instance Methods
message()
click to toggle source
# File lib/mine-sweeper/turn.rb, line 20 def message { row: @row, column: @column, action: @action } end
Private Instance Methods
action_is_valid?()
click to toggle source
# File lib/mine-sweeper/turn.rb, line 28 def action_is_valid? valid_actions.include? action end
valid_actions()
click to toggle source
# File lib/mine-sweeper/turn.rb, line 32 def valid_actions ["A","C","F","U"] end