Module: Inquirex::Transcript
- Defined in:
- lib/inquirex/transcript.rb
Overview
Formats what the user actually saw into the prose entries a :text
accumulator collects.
The Engine appends one entry per interaction — an answered question, a
skipped question, a display step advanced past — and never for a step the
engine elided on its own. A step removed by skip_if, or auto-skipped
because an extraction already answered it, was never on screen, so it must
not appear in a narrative that claims to be a record of the session.
Entries are plain prose rather than JSON because their only consumer is an
LLM prompt: Q: / A: reads as dialogue to a model, where a serialized
answers hash reads as data and produces a summary that sounds like one.
Constant Summary collapse
- SKIPPED =
Shown instead of an answer for a question the user declined.
"(skipped)"- NO_ANSWER =
Shown instead of an answer when a step somehow carries none.
"(no answer)"
Class Method Summary collapse
-
.answer_entry(node, answer) ⇒ String?
The entry for a question the user answered.
-
.display_entry(node) ⇒ String?
The entry for a display step (say/header/btw/warning) the user has just advanced past: its text, verbatim.
-
.format_answer(answer, node = nil) ⇒ String
Renders an answer the way it was shown, not the way it is stored: option values become their labels where the step declares them, so the narrative reads "Married filing jointly" rather than "married_filing_jointly".
-
.skipped_entry(node) ⇒ String?
The entry for an optional question the user declined.
Class Method Details
.answer_entry(node, answer) ⇒ String?
The entry for a question the user answered.
39 40 41 |
# File 'lib/inquirex/transcript.rb', line 39 def answer_entry(node, answer) exchange(node, format_answer(answer, node)) end |
.display_entry(node) ⇒ String?
The entry for a display step (say/header/btw/warning) the user has just advanced past: its text, verbatim.
29 30 31 32 |
# File 'lib/inquirex/transcript.rb', line 29 def display_entry(node) text = node.text.to_s.strip text.empty? ? nil : text end |
.format_answer(answer, node = nil) ⇒ String
Renders an answer the way it was shown, not the way it is stored: option values become their labels where the step declares them, so the narrative reads "Married filing jointly" rather than "married_filing_jointly".
59 60 61 62 63 64 65 66 67 |
# File 'lib/inquirex/transcript.rb', line 59 def format_answer(answer, node = nil) case answer when nil then NO_ANSWER when true then "Yes" when false then "No" when Array then format_array(answer, node) else label_for(answer, node) end end |
.skipped_entry(node) ⇒ String?
The entry for an optional question the user declined.
47 48 49 |
# File 'lib/inquirex/transcript.rb', line 47 def skipped_entry(node) exchange(node, SKIPPED) end |