Class: Omaship::ShipTypePicker
- Inherits:
-
Object
- Object
- Omaship::ShipTypePicker
- Includes:
- LinearPickerControls
- Defined in:
- lib/omaship/ship_type_picker.rb
Constant Summary collapse
- OPTIONS =
[ { key: "landing", label: "Landingpage", summary: "Public landing page with waitlist capture" }, { key: "app", label: "Full App", summary: "Authenticated product UI with dashboard" }, { key: "api", label: "Agent API", summary: "Agent-first API with CLI scaffolding" } ].freeze
- DEFAULT_INDEX =
1
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(out: $stdout, input: $stdin) ⇒ ShipTypePicker
constructor
A new instance of ShipTypePicker.
- #pick ⇒ Object
Constructor Details
#initialize(out: $stdout, input: $stdin) ⇒ ShipTypePicker
Returns a new instance of ShipTypePicker.
32 33 34 35 36 |
# File 'lib/omaship/ship_type_picker.rb', line 32 def initialize(out: $stdout, input: $stdin) @out = out @input = input @index = DEFAULT_INDEX end |
Class Method Details
.label_for(key) ⇒ Object
27 28 29 30 |
# File 'lib/omaship/ship_type_picker.rb', line 27 def self.label_for(key) option = OPTIONS.find { |entry| entry[:key] == key } option ? option[:label] : key.to_s end |
Instance Method Details
#pick ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/omaship/ship_type_picker.rb', line 38 def pick render loop do key = (@input) case key when :previous @index = (@index - 1) % OPTIONS.size render when :next @index = (@index + 1) % OPTIONS.size render when :enter, "q" return OPTIONS[@index][:key] when :ctrl_c raise Interrupt end end ensure @out.print "\e[?25h" @out.puts if @rendered_lines end |