Class: Vehicle
- Inherits:
-
Object
- Object
- Vehicle
- Defined in:
- vehicle.rb
Direct Known Subclasses
State Machines
This class contains 1 state machine(s).state

Instance Attribute Summary (collapse)
-
- (Object) state
Gets the current attribute value for the machine.
Class Method Summary (collapse)
-
+ (String) human_state_event_name(event)
Gets the humanized name for the given event.
-
+ (String) human_state_name(state)
Gets the humanized name for the given state.
Instance Method Summary (collapse)
-
- (Boolean) can_crash?(requirements = {})
Checks whether :crash can be fired.
-
- (Boolean) can_idle?(requirements = {})
Checks whether :idle can be fired.
-
- (Boolean) can_ignite?(requirements = {})
Checks whether :ignite can be fired.
-
- (Boolean) can_park?(requirements = {})
Checks whether :park can be fired.
-
- (Boolean) can_repair?(requirements = {})
Checks whether :repair can be fired.
-
- (Boolean) can_shift_down?(requirements = {})
Checks whether :shift_down can be fired.
-
- (Boolean) can_shift_up?(requirements = {})
Checks whether :shift_up can be fired.
-
- (Boolean) crash(*args)
Fires the :crash event.
-
- (Boolean) crash!(*args)
Fires the :crash event, raising an exception if it fails.
-
- (StateMachine::Transition) crash_transition(requirements = {})
Gets the next transition that would be performed if :crash were to be fired.
-
- (Boolean) fire_state_event(event, *args)
Fires an arbitrary state event with the given argument list.
-
- (Boolean) first_gear?
Checks whether :first_gear is the current state.
-
- (String) human_state_name
Gets the human-readable name of the state for the current value.
-
- (Boolean) idle(*args)
Fires the :idle event.
-
- (Boolean) idle!(*args)
Fires the :idle event, raising an exception if it fails.
-
- (StateMachine::Transition) idle_transition(requirements = {})
Gets the next transition that would be performed if :idle were to be fired.
-
- (Boolean) idling?
Checks whether :idling is the current state.
-
- (Boolean) ignite(*args)
Fires the :ignite event.
-
- (Boolean) ignite!(*args)
Fires the :ignite event, raising an exception if it fails.
-
- (StateMachine::Transition) ignite_transition(requirements = {})
Gets the next transition that would be performed if :ignite were to be fired.
-
- (Boolean) park(*args)
Fires the :park event.
-
- (Boolean) park!(*args)
Fires the :park event, raising an exception if it fails.
-
- (StateMachine::Transition) park_transition(requirements = {})
Gets the next transition that would be performed if :park were to be fired.
-
- (Boolean) parked?
Checks whether :parked is the current state.
-
- (Boolean) repair(*args)
Fires the :repair event.
-
- (Boolean) repair!(*args)
Fires the :repair event, raising an exception if it fails.
-
- (StateMachine::Transition) repair_transition(requirements = {})
Gets the next transition that would be performed if :repair were to be fired.
-
- (Boolean) second_gear?
Checks whether :second_gear is the current state.
-
- (Boolean) shift_down(*args)
Fires the :shift_down event.
-
- (Boolean) shift_down!(*args)
Fires the :shift_down event, raising an exception if it fails.
-
- (StateMachine::Transition) shift_down_transition(requirements = {})
Gets the next transition that would be performed if :shift_down were to be fired.
-
- (Boolean) shift_up(*args)
Fires the :shift_up event.
-
- (Boolean) shift_up!(*args)
Fires the :shift_up event, raising an exception if it fails.
-
- (StateMachine::Transition) shift_up_transition(requirements = {})
Gets the next transition that would be performed if :shift_up were to be fired.
-
- (Boolean) stalled?
Checks whether :stalled is the current state.
-
- (Boolean) state?(state_name)
Checks the given state name against the current state.
-
- (Array<Symbol>) state_events(requirements = {})
Gets the list of events that can be fired on the current state (uses the unqualified event names).
-
- (Symbol) state_name
Gets the internal name of the state for the current value.
-
- (StateMachine::PathCollection) state_paths(requirements = {})
Gets the list of sequences of transitions that can be run for the current state.
-
- (Array<StateMachine::Transition>) state_transitions(requirements = {})
Gets the list of transitions that can be made for the current state.
-
- (Boolean) third_gear?
Checks whether :third_gear is the current state.
Instance Attribute Details
- (Object) state
Gets the current attribute value for the machine
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
Class Method Details
+ (String) human_state_event_name(event)
Gets the humanized name for the given event.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
+ (String) human_state_name(state)
Gets the humanized name for the given state.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
Instance Method Details
- (Boolean) can_crash?(requirements = {})
Checks whether :crash can be fired.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) can_idle?(requirements = {})
Checks whether :idle can be fired.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) can_ignite?(requirements = {})
Checks whether :ignite can be fired.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) can_park?(requirements = {})
Checks whether :park can be fired.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) can_repair?(requirements = {})
Checks whether :repair can be fired.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) can_shift_down?(requirements = {})
Checks whether :shift_down can be fired.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) can_shift_up?(requirements = {})
Checks whether :shift_up can be fired.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) crash(*args)
Fires the :crash event.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) crash!(*args)
Fires the :crash event, raising an exception if it fails.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (StateMachine::Transition) crash_transition(requirements = {})
Gets the next transition that would be performed if :crash were to be fired.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) fire_state_event(event, *args)
Fires an arbitrary state event with the given argument list
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) first_gear?
Checks whether :first_gear is the current state.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (String) human_state_name
Gets the human-readable name of the state for the current value.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) idle(*args)
Fires the :idle event.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) idle!(*args)
Fires the :idle event, raising an exception if it fails.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (StateMachine::Transition) idle_transition(requirements = {})
Gets the next transition that would be performed if :idle were to be fired.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) idling?
Checks whether :idling is the current state.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) ignite(*args)
Fires the :ignite event.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) ignite!(*args)
Fires the :ignite event, raising an exception if it fails.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (StateMachine::Transition) ignite_transition(requirements = {})
Gets the next transition that would be performed if :ignite were to be fired.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) park(*args)
Fires the :park event.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) park!(*args)
Fires the :park event, raising an exception if it fails.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (StateMachine::Transition) park_transition(requirements = {})
Gets the next transition that would be performed if :park were to be fired.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) parked?
Checks whether :parked is the current state.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) repair(*args)
Fires the :repair event.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) repair!(*args)
Fires the :repair event, raising an exception if it fails.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (StateMachine::Transition) repair_transition(requirements = {})
Gets the next transition that would be performed if :repair were to be fired.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) second_gear?
Checks whether :second_gear is the current state.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) shift_down(*args)
Fires the :shift_down event.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) shift_down!(*args)
Fires the :shift_down event, raising an exception if it fails.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (StateMachine::Transition) shift_down_transition(requirements = {})
Gets the next transition that would be performed if :shift_down were to be fired.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) shift_up(*args)
Fires the :shift_up event.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) shift_up!(*args)
Fires the :shift_up event, raising an exception if it fails.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (StateMachine::Transition) shift_up_transition(requirements = {})
Gets the next transition that would be performed if :shift_up were to be fired.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) stalled?
Checks whether :stalled is the current state.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) state?(state_name)
Checks the given state name against the current state.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Array<Symbol>) state_events(requirements = {})
Gets the list of events that can be fired on the current state (uses the unqualified event names)
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Symbol) state_name
Gets the internal name of the state for the current value.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (StateMachine::PathCollection) state_paths(requirements = {})
Gets the list of sequences of transitions that can be run for the current state
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Array<StateMachine::Transition>) state_transitions(requirements = {})
Gets the list of transitions that can be made for the current state
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |
- (Boolean) third_gear?
Checks whether :third_gear is the current state.
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'vehicle.rb', line 4 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 |