Module: Inputable

Included in:
OpeningAct
Defined in:
lib/opening_act/input.rb

Overview

Module containing method for user inputs

Instance Method Summary collapse

Instance Method Details

#command_inputObject



3
4
5
6
7
8
9
10
11
# File 'lib/opening_act/input.rb', line 3

def command_input
  appropriate_commands = %w[add overwrite q quit rename]

  loop do
    command = user_input.downcase
    return command if appropriate_commands.include? command
    puts '> Invalid entry. Please enter ADD/OVERWRITE/QUIT/RENAME'
  end
end

#project_name_inputObject



13
14
15
16
17
18
19
20
21
# File 'lib/opening_act/input.rb', line 13

def project_name_input
  loop do
    puts '> What do you want to name your project?'
    project_name = user_input

    return project_name if valid_name?(project_name)
    puts '> Invalid characters. Please try again'
  end
end

#test_type_inputObject



23
24
25
26
27
28
29
30
31
# File 'lib/opening_act/input.rb', line 23

def test_type_input
  loop do
    puts '> Do you prefer rspec or minitest?'
    test_type = '-' + user_input.downcase

    return test_type if valid_test? test_type
    puts '> Invalid entry.'
  end
end

#user_inputObject



33
34
35
# File 'lib/opening_act/input.rb', line 33

def user_input
  $stdin.gets.chomp
end