Sha256: 444630495909cdb2ecb9e77e815940a2a12604b88bd78cae99c340f936f0737c

Contents?: true

Size: 516 Bytes

Versions: 5

Compression:

Stored size: 516 Bytes

Contents

require 'microfsm'

# This example can be run with ruby -I lib/ ./examples/basic.rb

fsm = MicroFSM.new(:pending)
        .when(:confirm,  :pending => :confirmed)
        .when(:ignore,   :pending => :ignored)
        .when(:reset,    :confirmed => :pending, :ignored => :pending)

puts "Should print Confirmed, Reset and Ignored:"

if fsm.trigger(:confirm)
  puts "Confirmed"
end

if fsm.trigger(:ignore)
  puts "Ignored"
end

if fsm.trigger(:reset)
  puts "Reset"
end

if fsm.trigger(:ignore)
  puts "Ignored"
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
microfsm-0.1.3 examples/basic.rb
microfsm-0.1.2 examples/basic.rb
microfsm-0.1.1 examples/basic.rb
microfsm-0.1.0 examples/basic.rb
microfsm-0.0.1 examples/basic.rb