Class: LifecycleVM::VM::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/lifecycle_vm/vm.rb

Overview

Stores state machine configuration.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Creates a new Config with default settings



51
52
53
54
55
56
57
58
59
60
# File 'lib/lifecycle_vm/vm.rb', line 51

def initialize
  @states = {}
  @on_op_failure = DEFAULT_ON_OP_FAILURE
  @initial_state = DEFAULT_START
  @terminal_states = DEFAULT_TERMINALS
  @memory_class = LifecycleVM::Memory
  @terminal_states.each do |state|
    @states[state] ||= State.new(state, {})
  end
end

Instance Attribute Details

#initial_stateSymbol

Returns the state to start at.

Returns:

  • (Symbol)

    the state to start at



41
42
43
# File 'lib/lifecycle_vm/vm.rb', line 41

def initial_state
  @initial_state
end

#memory_classLifecycleVM::Memory

Returns not an instance of but the class of the memory for this particular machine.

Returns:

  • (LifecycleVM::Memory)

    not an instance of but the class of the memory for this particular machine



48
49
50
# File 'lib/lifecycle_vm/vm.rb', line 48

def memory_class
  @memory_class
end

#on_op_failureSymbol?

Returns the state to transition to when an op fails.

Returns:

  • (Symbol, nil)

    the state to transition to when an op fails



35
36
37
# File 'lib/lifecycle_vm/vm.rb', line 35

def on_op_failure
  @on_op_failure
end

#statesHash<Symbol, LifecycleVM::State>

Returns a mapping of state names to state structures.

Returns:



38
39
40
# File 'lib/lifecycle_vm/vm.rb', line 38

def states
  @states
end

#terminal_statesArray<Symbol>

Returns a list of state names which the machine will stop at.

Returns:

  • (Array<Symbol>)

    a list of state names which the machine will stop at



44
45
46
# File 'lib/lifecycle_vm/vm.rb', line 44

def terminal_states
  @terminal_states
end