Skip to content

ascaridol/mruby-statemachine

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

mruby-statemachine

A tiny State Machine for mruby

Example

class Fsm
  include StateMachine

  attr_reader :started, :ended

  def initialize
    @started, @ended = false, false
  end

  state :start, to: [:hello, :end] do
    @started = true
  end

  state :hello, to: [:end]

  state :end, to: [] do
    @ended = true
    @started = false
  end
end

fsm = Fsm.new
fsm.transition :start
fsm.state.name == :start
fsm.started == true
fsm.transition :hello
fsm.state.name == :hello
fsm.transition :end
fsm.state.name == :end
fsm.ended == true
fsm.started == false

Releases

No releases published

Packages

No packages published

Languages