Class: BundleUpdateInteractive::CLI::MultiSelect
- Inherits:
-
Object
- Object
- BundleUpdateInteractive::CLI::MultiSelect
- Extended by:
- StringHelper
- 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:, opener: nil, prompt: nil) ⇒ MultiSelect
constructor
A new instance of MultiSelect.
- #prompt ⇒ Object
Methods included from StringHelper
Constructor Details
#initialize(title:, table:, opener: nil, prompt: nil) ⇒ MultiSelect
Returns a new instance of MultiSelect.
62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/bundle_update_interactive/cli/multi_select.rb', line 62 def initialize(title:, table:, opener: nil, prompt: nil) @title = title @table = table @opener = opener @tty_prompt = prompt || TTY::Prompt.new( interrupt: lambda { puts exit(130) } ) @pastel = BundleUpdateInteractive.pastel end |
Class Method Details
.prompt_for_gems_to_update(outdated_gems, prompt: nil) ⇒ Object
51 52 53 54 55 56 57 58 59 60 |
# File 'lib/bundle_update_interactive/cli/multi_select.rb', line 51 def self.prompt_for_gems_to_update(outdated_gems, prompt: nil) table = Table.updatable(outdated_gems) title = "#{pluralize(outdated_gems.length, 'gem')} can be updated." opener = lambda do |gem| url = outdated_gems[gem].changelog_uri Launchy.open(url) unless url.nil? end chosen = new(title: title, table: table, prompt: prompt, opener: opener).prompt outdated_gems.slice(*chosen) end |
Instance Method Details
#prompt ⇒ Object
75 76 77 78 |
# File 'lib/bundle_update_interactive/cli/multi_select.rb', line 75 def prompt choices = table.gem_names.to_h { |name| [table.render_gem(name), name] } tty_prompt.invoke_select(List, title, choices, help: help, opener: opener) end |