Class: Inquirex::TTY::Renderer
- Inherits:
-
Object
- Object
- Inquirex::TTY::Renderer
- Includes:
- UIHelper
- Defined in:
- lib/inquirex/tty/renderer.rb
Overview
Renders flow nodes as interactive TTY prompts. Dispatches collecting steps
via the node's TTY widget hint (from Inquirex::WidgetRegistry or an
explicit widget target: :tty declaration in the DSL).
Display verbs render text/boxes and return nil; the caller is responsible
for calling engine.advance.
Widget type → tty-prompt method:
text_input → prompt.ask
multiline → line-by-line collector (empty line submits)
number_input → prompt.ask(convert: :int / :float)
currency_input → prompt.ask(convert: :float)
yes_no → prompt.yes?
select → prompt.select
multi_select → prompt.multi_select
enum_select → prompt.enum_select
mask → prompt.mask
slider → prompt.slider
(fallback) → prompt.ask
Header display verb uses TTY::Font for large ASCII-art section titles.
Instance Attribute Summary collapse
- #prompt ⇒ TTY::Prompt readonly
Instance Method Summary collapse
-
#initialize(prompt: ::TTY::Prompt.new) ⇒ Renderer
constructor
A new instance of Renderer.
-
#render(node) ⇒ Object?
Renders a node.
-
#show_extraction(result) ⇒ void
Prints the structured data extracted by a clarify step, dimming any fields the LLM left blank so the user can see what still needs asking.
-
#thinking(message) ⇒ void
Prints a "thinking" line before the LLM adapter is called.
Methods included from UIHelper
Constructor Details
#initialize(prompt: ::TTY::Prompt.new) ⇒ Renderer
Returns a new instance of Renderer.
33 34 35 |
# File 'lib/inquirex/tty/renderer.rb', line 33 def initialize(prompt: ::TTY::Prompt.new) @prompt = prompt end |
Instance Attribute Details
#prompt ⇒ TTY::Prompt (readonly)
30 31 32 |
# File 'lib/inquirex/tty/renderer.rb', line 30 def prompt @prompt end |
Instance Method Details
#render(node) ⇒ Object?
Renders a node. Returns the collected answer, or nil for display verbs.
68 69 70 71 72 73 74 75 |
# File 'lib/inquirex/tty/renderer.rb', line 68 def render(node) if node.display? render_display_verb(node) nil else render_collecting(node) end end |
#show_extraction(result) ⇒ void
This method returns an undefined value.
Prints the structured data extracted by a clarify step, dimming any fields the LLM left blank so the user can see what still needs asking.
53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/inquirex/tty/renderer.rb', line 53 def show_extraction(result) puts pastel.bold("📋 LLM extracted:") result.each do |key, value| if value.nil? || (value.respond_to?(:empty?) && value.empty?) puts pastel.dim(" ❓ #{key}: (unknown — will ask)") else puts pastel.green(" ✅ #{key}: #{value.inspect}") end end sep(:magenta, "─") end |
#thinking(message) ⇒ void
This method returns an undefined value.
Prints a "thinking" line before the LLM adapter is called. Plain colored text — no animation so it plays nicely with piped output.
42 43 44 45 46 |
# File 'lib/inquirex/tty/renderer.rb', line 42 def thinking() sep(:magenta, "─") puts pastel.bright_magenta.bold() sep(:magenta, "─") end |