struct

FSM::State

Inherits Struct < Value < Object

Represents a state within the finite state machine.

@property id [String] The unique identifier of the state. @property transitions [Hash(String, Transition)] A collection of transitions associated with the state. @property entry_callbacks [Callable(String, Context)?] Optional callback to be executed when entering the state. @property exit_callbacks [Callable(String, Context)?] Optional callback to be executed when exiting the state.

Class methods

create(id : String)

Create a new state with the given identifier.

@param id [String] The unique identifier of the state.

Source
create(id : String, &)

Create a new state with the given identifier and execute a block to set up additional configurations.

@param id [String] The unique identifier of the state. @yieldparam self [State] The state instance to be configured.

Source

Instance methods

==(other : State)

Compare two states for equality based on their identifiers.

@param other [State] The state to compare with.

Source
all_target_states

Get a list of all target states reachable through transitions from this state.

Source
id

The unique identifier of the state.

Source
on_entry

Register a new callback to be fired when entering this state.

@yieldparam event [String] The event triggering the entry callback. @yieldparam context [Context] The context associated with the state machine.

Source
on_event(event : String, target : String) : self

Register a new transition from this state to another state.

@param event [String] The event triggering the transition. @param target [String] The target state after the transition.

Source
on_event(event : String, target : String, &) : self

Register a new transition with a callback to be executed when the transition is made.

@param event [String] The event triggering the transition. @param target [String] The target state after the transition. @yieldparam event [String] The event triggering the transition. @yieldparam context [Context] The context associated with the state machine.

Source
on_exit

Register new callbacks to be fired when exiting this state.

@yieldparam event [String] The event triggering the exit callbacks. @yieldparam context [Context] The context associated with the state machine.

Source