Class: Input

Inherits:
Object
  • Object
show all
Defined in:
lib/easy_portfolio/input.rb

Constant Summary collapse

VALID_OPTIONS =
%w(y n)

Instance Method Summary collapse

Instance Method Details

#action_verified?(input) ⇒ Boolean

Returns:

  • (Boolean)


12
13
14
# File 'lib/easy_portfolio/input.rb', line 12

def action_verified?(input)
  input.downcase == 'y' ? true : false
end

#ask_yes_or_noObject



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

def ask_yes_or_no
  loop do 
    answer = command_line_input.downcase
    return answer if VALID_OPTIONS.include?(answer)
    puts 'Please input either y (yes) or n (no).'
  end
end