Class: TTY::Prompt::Question
- Inherits:
-
Object
- Object
- TTY::Prompt::Question
- Defined in:
- lib/terjira/ext/tty_prompt.rb
Instance Method Summary collapse
-
#encode_input(line) ⇒ Boolean
private
Encod input.
-
#process_input ⇒ Object
private
Decide how to handle input from user.
Instance Method Details
#encode_input(line) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Encod input
29 30 31 |
# File 'lib/terjira/ext/tty_prompt.rb', line 29 def encode_input(line) line.codepoints.to_a.pack('C*').force_encoding('utf-8') end |
#process_input ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Decide how to handle input from user
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/terjira/ext/tty_prompt.rb', line 9 def process_input @input = read_input if Utils.blank?(@input) @input = default? ? default : nil end if @input.is_a? String @input = encode_input(@input) elsif @input.is_a? Array @input = @input.map { |input| encode_input(input) } end @evaluator.(@input) end |