Class: TTY::Prompt::MultiList Private
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A class responsible for rendering multi select list menu. Used by TTY::Prompt to display interactive choice menu.
Constant Summary collapse
- HELP =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
'(Use arrow%s keys, press Space to select and Enter to finish)'.freeze
Constants inherited from List
Constants included from Symbols
Symbols::KEYS, Symbols::WIN_KEYS
Instance Method Summary collapse
-
#initialize(prompt, options) ⇒ MultiList
constructor
Create instance of TTY::Prompt::MultiList menu.
-
#keyspace ⇒ Object
private
Callback fired when space key is pressed.
Methods inherited from List
#call, #choice, #choices, #default, #default_help, #enum, #enumerate?, #help, #keydown, #keynum, #keyreturn, #keyup, #marker, #page_help, #page_size, #paginated?, #per_page
Methods included from Symbols
Constructor Details
#initialize(prompt, options) ⇒ MultiList
Create instance of TTY::Prompt::MultiList menu.
20 21 22 23 24 25 26 |
# File 'lib/tty/prompt/multi_list.rb', line 20 def initialize(prompt, ) super @selected = [] @help = [:help] @default = Array([:default]) @echo = .fetch(:echo, true) end |
Instance Method Details
#keyspace ⇒ 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.
Callback fired when space key is pressed
31 32 33 34 35 36 37 38 |
# File 'lib/tty/prompt/multi_list.rb', line 31 def keyspace(*) active_choice = @choices[@active - 1] if @selected.include?(active_choice) @selected.delete(active_choice) else @selected << active_choice end end |