The next_node
method takes a block that should return the next node (question or outcome) to send the user to. The relevant node key must be returned via the question
or outcome
method.
next_node do |response|
if response == 'green'
question :green? # Go to the :green? question node
else
outcome :red # Go to the :red outcome node
end
end
Occurs if next_node
is called more than once within a single question block.
# For example
next_node do
outcome :red
end
next_node do
question :green?
end
Occurs if next_node
is called without a block.
# For example
next_node
Occurs if the next_node
block returns something "falsey" (e.g. nil
).
# For example
next_node do
nil
end
Occurs if the next_node
block returns something which was not returned by a
call to #question
or #outcome
.
# For example
next_node do
:green?
end
Occurs if the next_node
blocks returns a value that isn't defined as a question or outcome node.
# For example
next_node do
outcome :red
end
outcome :blue