Sha256: cb2614fcb5fd65d44e3c4f0d9eaeb740c101849e99ef7319a5878f32a0a97b94

Contents?: true

Size: 943 Bytes

Versions: 3

Compression:

Stored size: 943 Bytes

Contents

class Vehicle
  state_machine :initial => :parked do
    event :park do
      transition :to => :parked, :from => [:idling, :first_gear]
    end
    
    event :ignite do
      transition :to => :stalled, :from => :stalled
      transition :to => :idling, :from => :parked
    end
    
    event :idle do
      transition :to => :idling, :from => :first_gear
    end
    
    event :shift_up do
      transition :to => :first_gear, :from => :idling
      transition :to => :second_gear, :from => :first_gear
      transition :to => :third_gear, :from => :second_gear
    end
    
    event :shift_down do
      transition :to => :second_gear, :from => :third_gear
      transition :to => :first_gear, :from => :second_gear
    end
    
    event :crash do
      transition :to => :stalled, :from => [:first_gear, :second_gear, :third_gear]
    end
    
    event :repair do
      transition :to => :parked, :from => :stalled
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
state_machine-0.5.1 examples/vehicle.rb
state_machine-0.5.0 examples/vehicle.rb
state_machine-0.5.2 examples/vehicle.rb