https://github.com/ascaridol/mruby-statemachine
A tiny state machine for mruby
https://github.com/ascaridol/mruby-statemachine
Last synced: 6 months ago
JSON representation
A tiny state machine for mruby
- Host: GitHub
- URL: https://github.com/ascaridol/mruby-statemachine
- Owner: ascaridol
- License: apache-2.0
- Created: 2015-12-23T22:06:57.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-12-30T06:14:34.000Z (over 9 years ago)
- Last Synced: 2024-08-03T08:02:36.827Z (9 months ago)
- Language: Ruby
- Homepage:
- Size: 9.77 KB
- Stars: 2
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-mruby - mruby-statemachine - a tiny state machine for mruby. (Utilities)
README
[](https://travis-ci.org/ascaridol/mruby-statemachine)
# mruby-statemachine
A tiny State Machine for mrubyExample
=======```ruby
class Fsm
include StateMachineattr_reader :started, :ended
def initialize
@started, @ended = false, false
endstate :start, to: [:hello, :end] do
@started = true
endstate :hello, to: [:end]
state :end, to: [] do
@ended = true
@started = false
end
endfsm = 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
```