Method: Amp::UI#ask
- Defined in:
- lib/amp/support/amp_ui.rb
#ask(question = '', type = String) ⇒ String
Ask question and return the answer, chomped
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/amp/support/amp_ui.rb', line 165 def ask(question='', type=String) type = type.to_s.downcase.to_sym print question.to_s result = gets.chomp unless type == :password # type conversion case type when :string result when :integer, :fixnum, :bignum, :numeric result.to_i when :array result.split(',').map {|e| e.strip } when :password get_pass else raise abort("Don't know how to convert to type #{type}") end end |