Class: CLI
- Inherits:
-
Object
- Object
- CLI
- Defined in:
- lib/cli.rb
Constant Summary collapse
- OFFSET =
1
Instance Method Summary collapse
- #choose_player_type(options) ⇒ Object
- #get_valid_input(options) ⇒ Object
-
#initialize(input = $stdin, output = $stdout) ⇒ CLI
constructor
A new instance of CLI.
- #place_marker(options) ⇒ Object
- #select_board_size(options) ⇒ Object
Constructor Details
#initialize(input = $stdin, output = $stdout) ⇒ CLI
Returns a new instance of CLI.
12 13 14 15 16 |
# File 'lib/cli.rb', line 12 def initialize(input=$stdin, output=$stdout) @input = input @output = output run_app end |
Instance Method Details
#choose_player_type(options) ⇒ Object
22 23 24 |
# File 'lib/cli.rb', line 22 def choose_player_type() get_valid_input() end |
#get_valid_input(options) ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/cli.rb', line 31 def get_valid_input() choice = @input.gets.chomp.to_i if .include? choice choice else @output.puts "Invalid Selection" get_valid_input() end end |
#place_marker(options) ⇒ Object
26 27 28 29 |
# File 'lib/cli.rb', line 26 def place_marker() offset_spaces = .map {|space| space + OFFSET} get_valid_input(offset_spaces) - OFFSET end |
#select_board_size(options) ⇒ Object
18 19 20 |
# File 'lib/cli.rb', line 18 def select_board_size() get_valid_input() end |