Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

34 lines (26 sloc) 0.746 kB
require 'state_machine'
class Vehicle
state_machine :initial => :parked do
event :park do
transition [:idling, :first_gear] => :parked
end
event :ignite do
transition :stalled => same, :parked => :idling
end
event :idle do
transition :first_gear => :idling
end
event :shift_up do
transition :idling => :first_gear, :first_gear => :second_gear, :second_gear => :third_gear
end
event :shift_down do
transition :third_gear => :second_gear, :second_gear => :first_gear
end
event :crash do
transition [:first_gear, :second_gear, :third_gear] => :stalled
end
event :repair do
transition :stalled => :parked
end
end
end
Jump to Line
Something went wrong with that request. Please try again.