File: car.rb

package info (click to toggle)
ruby-state-machine 1.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,764 kB
  • ctags: 6,623
  • sloc: ruby: 26,008; makefile: 11
file content (21 lines) | stat: -rw-r--r-- 392 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
require 'state_machine'

class Car < Vehicle
  state_machine do
    event :reverse do
      transition [:parked, :idling, :first_gear] => :backing_up
    end
    
    event :park do
      transition :backing_up => :parked
    end
    
    event :idle do
      transition :backing_up => :idling
    end
    
    event :shift_up do
      transition :backing_up => :first_gear
    end
  end
end