Class: UserInput::Boolean

Inherits:
Prompt
  • Object
show all
Defined in:
lib/userinput/boolean.rb

Overview

Helper class for asking yes/no questions

Instance Method Summary collapse

Constructor Details

#initialize(params = {}) ⇒ Boolean

Returns a new instance of Boolean.


5
6
7
8
9
# File 'lib/userinput/boolean.rb', line 5

def initialize(params = {})
  super
  @validation = /(y|yes|n|no)/i
  @separator = ' [y/n]?' if @separator == '?'
end

Instance Method Details

#askObject


11
12
13
# File 'lib/userinput/boolean.rb', line 11

def ask
  super =~ /y/i ? true : false
end