Class: BundleUpdateInteractive::CLI::MultiSelect
- Inherits:
-
Object
- Object
- BundleUpdateInteractive::CLI::MultiSelect
- Defined in:
- lib/bundle_update_interactive/cli/multi_select.rb
Defined Under Namespace
Classes: List
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(title:, table:) ⇒ MultiSelect
constructor
A new instance of MultiSelect.
- #prompt ⇒ Object
Constructor Details
#initialize(title:, table:) ⇒ MultiSelect
Returns a new instance of MultiSelect.
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/bundle_update_interactive/cli/multi_select.rb', line 33 def initialize(title:, table:) @title = title @table = table @tty_prompt = TTY::Prompt.new( interrupt: lambda { puts exit(130) } ) @pastel = BundleUpdateInteractive.pastel end |
Class Method Details
.prompt_for_gems_to_update(outdated_gems) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/bundle_update_interactive/cli/multi_select.rb', line 26 def self.prompt_for_gems_to_update(outdated_gems) table = Table.new(outdated_gems) title = "#{outdated_gems.length} gems can be updated." chosen = new(title: title, table: table).prompt outdated_gems.slice(*chosen) end |
Instance Method Details
#prompt ⇒ Object
45 46 47 48 |
# File 'lib/bundle_update_interactive/cli/multi_select.rb', line 45 def prompt choices = table.gem_names.to_h { |name| [table.render_gem(name), name] } tty_prompt.invoke_select(List, title, choices, help: help) end |