Module: StatesLanguageMachine

Defined in:
lib/ruby_slm.rb,
lib/ruby_slm/state.rb,
lib/ruby_slm/errors.rb,
lib/ruby_slm/version.rb,
lib/ruby_slm/execution.rb,
lib/ruby_slm/states/base.rb,
lib/ruby_slm/states/fail.rb,
lib/ruby_slm/states/pass.rb,
lib/ruby_slm/states/task.rb,
lib/ruby_slm/states/wait.rb,
lib/ruby_slm/state_machine.rb,
lib/ruby_slm/states/choice.rb,
lib/ruby_slm/states/succeed.rb,
lib/ruby_slm/states/parallel.rb

Defined Under Namespace

Modules: States Classes: DefinitionError, Error, Execution, ExecutionError, State, StateMachine, StateNotFoundError, TimeoutError

Constant Summary collapse

VERSION =
"0.1.1"

Class Method Summary collapse

Class Method Details

.from_hash(hash) ⇒ StateMachine

Create a state machine from a Hash

Parameters:

  • hash (Hash)

    the Hash definition of the state machine

Returns:



46
47
48
# File 'lib/ruby_slm.rb', line 46

def from_hash(hash)
  StateMachine.new(hash, format: :hash)
end

.from_json(json_string) ⇒ StateMachine

Create a state machine from a JSON string

Parameters:

  • json_string (String)

    the JSON definition of the state machine

Returns:



39
40
41
# File 'lib/ruby_slm.rb', line 39

def from_json(json_string)
  StateMachine.new(json_string, format: :json)
end

.from_yaml(yaml_string) ⇒ StateMachine

Create a state machine from a YAML string

Parameters:

  • yaml_string (String)

    the YAML definition of the state machine

Returns:



24
25
26
# File 'lib/ruby_slm.rb', line 24

def from_yaml(yaml_string)
  StateMachine.new(yaml_string)
end

.from_yaml_file(file_path) ⇒ StateMachine

Create a state machine from a YAML file

Parameters:

  • file_path (String)

    the path to the YAML file

Returns:



31
32
33
34
# File 'lib/ruby_slm.rb', line 31

def from_yaml_file(file_path)
  yaml_content = File.read(file_path)
  StateMachine.new(yaml_content)
end