Skip to content

prafiny/automaton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

automaton

Automaton handler for ruby

Example

Here's an example from the test suite

require_relative '../lib/automaton'

class Robot
  include Automaton
  attr_reader :n

  def initialize n
    @n = n

    def_automaton do
      state :increase do
        transition_to(:decrease) { @n > 100 } 

        behaviour do
          @n += 1
        end
      end

      state :decrease do
        transition_to(:increase) { @n < -100 }

        behaviour do
          @n -= 1
        end
      end
    end

  end

  def move
    act
    evaluate_state
  end
end

About

Automaton handler for ruby

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages