Class: StatesLanguageMachine::States::Base
- Inherits:
-
StatesLanguageMachine::State
- Object
- StatesLanguageMachine::State
- StatesLanguageMachine::States::Base
- Defined in:
- lib/ruby_slm/states/base.rb
Instance Attribute Summary collapse
-
#comment ⇒ String?
readonly
The comment describing the state.
-
#definition ⇒ Hash
readonly
The raw state definition.
Attributes inherited from StatesLanguageMachine::State
#end_state, #name, #next_state, #type
Instance Method Summary collapse
-
#initialize(name, definition) ⇒ Base
constructor
A new instance of Base.
-
#validate! ⇒ Object
Validate the state definition.
Methods inherited from StatesLanguageMachine::State
#end_state?, #execute, #next_state_name
Constructor Details
#initialize(name, definition) ⇒ Base
Returns a new instance of Base.
13 14 15 16 17 |
# File 'lib/ruby_slm/states/base.rb', line 13 def initialize(name, definition) super(name, definition) @comment = definition["Comment"] @definition = definition end |
Instance Attribute Details
#comment ⇒ String? (readonly)
Returns the comment describing the state.
7 8 9 |
# File 'lib/ruby_slm/states/base.rb', line 7 def comment @comment end |
#definition ⇒ Hash (readonly)
Returns the raw state definition.
9 10 11 |
# File 'lib/ruby_slm/states/base.rb', line 9 def definition @definition end |
Instance Method Details
#validate! ⇒ Object
Validate the state definition
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/ruby_slm/states/base.rb', line 21 def validate! # Base validation - can be overridden by subclasses if @end_state && @next_state raise DefinitionError, "State '#{@name}' cannot have both End and Next" end unless @end_state || @next_state raise DefinitionError, "State '#{@name}' must have either End or Next" end end |