Class: Inquirex::DSL::FlowBuilder
- Inherits:
-
Object
- Object
- Inquirex::DSL::FlowBuilder
- Includes:
- RuleHelpers
- Defined in:
- lib/inquirex/dsl/flow_builder.rb
Overview
Builds a Definition from the declarative DSL block used in Inquirex.define. Provides start, meta, and all verb methods (ask, say, header, btw, warning, confirm).
Instance Method Summary collapse
-
#ask(id) { ... } ⇒ Object
Defines a question step that collects typed input from the user.
-
#btw(id) ⇒ Object
Defines an admonition or sidebar note step (no input collected).
-
#build ⇒ Definition
Produces the frozen Definition.
-
#confirm(id) ⇒ Object
Defines a yes/no confirmation gate (collects a boolean answer).
-
#header(id) ⇒ Object
Defines a section heading step (no input collected).
-
#initialize(id: nil, version: "1.0.0") ⇒ FlowBuilder
constructor
A new instance of FlowBuilder.
-
#meta(title: nil, subtitle: nil, brand: nil) ⇒ Object
Sets frontend metadata: title, subtitle, and brand information.
-
#say(id) ⇒ Object
Defines an informational message step (no input collected).
-
#start(step_id) ⇒ Object
Sets the entry step id for the flow.
-
#warning(id) ⇒ Object
Defines an important alert step (no input collected).
Methods included from RuleHelpers
#all, #any, #contains, #equals, #greater_than, #less_than, #not_empty
Constructor Details
#initialize(id: nil, version: "1.0.0") ⇒ FlowBuilder
Returns a new instance of FlowBuilder.
12 13 14 15 16 17 18 |
# File 'lib/inquirex/dsl/flow_builder.rb', line 12 def initialize(id: nil, version: "1.0.0") @flow_id = id @flow_version = version @start_step_id = nil @nodes = {} @meta = {} end |
Instance Method Details
#ask(id) { ... } ⇒ Object
Defines a question step that collects typed input from the user.
42 43 44 |
# File 'lib/inquirex/dsl/flow_builder.rb', line 42 def ask(id, &) add_step(id, :ask, &) end |
#btw(id) ⇒ Object
Defines an admonition or sidebar note step (no input collected).
63 64 65 |
# File 'lib/inquirex/dsl/flow_builder.rb', line 63 def btw(id, &) add_step(id, :btw, &) end |
#build ⇒ Definition
Produces the frozen Definition.
85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/inquirex/dsl/flow_builder.rb', line 85 def build raise Errors::DefinitionError, "No start step defined" if @start_step_id.nil? raise Errors::DefinitionError, "No steps defined" if @nodes.empty? Definition.new( start_step_id: @start_step_id, nodes: @nodes, id: @flow_id, version: @flow_version, meta: @meta ) end |
#confirm(id) ⇒ Object
Defines a yes/no confirmation gate (collects a boolean answer).
77 78 79 |
# File 'lib/inquirex/dsl/flow_builder.rb', line 77 def confirm(id, &) add_step(id, :confirm, &) end |
#header(id) ⇒ Object
Defines a section heading step (no input collected).
56 57 58 |
# File 'lib/inquirex/dsl/flow_builder.rb', line 56 def header(id, &) add_step(id, :header, &) end |
#meta(title: nil, subtitle: nil, brand: nil) ⇒ Object
Sets frontend metadata: title, subtitle, and brand information.
32 33 34 35 36 |
# File 'lib/inquirex/dsl/flow_builder.rb', line 32 def (title: nil, subtitle: nil, brand: nil) @meta[:title] = title if title @meta[:subtitle] = subtitle if subtitle @meta[:brand] = brand if brand end |
#say(id) ⇒ Object
Defines an informational message step (no input collected).
49 50 51 |
# File 'lib/inquirex/dsl/flow_builder.rb', line 49 def say(id, &) add_step(id, :say, &) end |
#start(step_id) ⇒ Object
Sets the entry step id for the flow.
23 24 25 |
# File 'lib/inquirex/dsl/flow_builder.rb', line 23 def start(step_id) @start_step_id = step_id end |
#warning(id) ⇒ Object
Defines an important alert step (no input collected).
70 71 72 |
# File 'lib/inquirex/dsl/flow_builder.rb', line 70 def warning(id, &) add_step(id, :warning, &) end |