Module Interactive
In: lib/interact/interactive.rb

Copyright (c) 2012 Alex Suraci

Methods

ask   read_char   read_event   read_line  

Classes and Modules

Module Interactive::Rewindable
Class Interactive::InputState

Constants

EVENTS = { "\b" => :backspace, "\t" => :tab, "\x01" => :home, "\x03" => :interrupt, "\x04" => :eof, "\x05" => :end, "\x17" => :kill_word, "\x7f" => :backspace, "\r" => :enter, "\n" => :enter
ESCAPES = { "[A" => :up, "H" => :up, "[B" => :down, "P" => :down, "[C" => :right, "M" => :right, "[D" => :left, "K" => :left, "[3~" => :delete, "S" => :delete, "[H" => :home, "G" => :home, "[F" => :end, "O" => :end

Public Instance methods

Ask a question and get an answer.

See Interact#read_line for the other possible values in options.

question
The prompt, without ": " at the end.
options
An optional hash containing the following options.
default:The default value, also used to attempt type conversion of the answer (e.g. numeric/boolean).
choices:An array (or Enumerable) of strings to choose from.
indexed:Use alternative choice listing, and allow choosing by number. Good for when there are many choices or choices with long names.

Read a single character.

options
An optional hash containing the following options.
input:The input source (defaults to $stdin).

Read a single event.

options
An optional hash containing the following options.
input:The input source (defaults to $stdin).

Read a line of input.

options
An optional hash containing the following options.
input:The input source (defaults to $stdin).
echo:A string to echo when showing the input; used for things like hiding password input.

[Validate]