module Finite
The Finite
module. The module that contains all the classes and methods for the finite gem.
Constants
- VERSION
The version number
Public Class Methods
included(base)
click to toggle source
Override included method
Calls superclass method
# File lib/finite.rb, line 15 def self.included(base) base.extend(ClassMethods) super end
Public Instance Methods
callbacks()
click to toggle source
Get’s (and sets) the array of callbacks @return the array of callbacks
# File lib/finite/finite.rb, line 25 def callbacks @callbacks ||= StateMachine.machines[self.class].callbacks @callbacks end
current_state()
click to toggle source
Get’s the current state @return the current state for an object
# File lib/finite/finite.rb, line 4 def current_state machine = StateMachine.machines[self.class] @current_state or machine.states[machine.initial] end
events()
click to toggle source
Get’s (and sets) the array of events @return the array of events
# File lib/finite/finite.rb, line 18 def events @events ||= StateMachine.machines[self.class].events @events end
possible_events()
click to toggle source
Get’s all the possible events you can perform @return any event that you can perform given your state
# File lib/finite/finite.rb, line 32 def possible_events pos = Array.new events.each_value{|event| pos << event if event.transitions.key?(current_state.name)} pos end
states()
click to toggle source
Get’s (and sets) the array of states @return the array of states
# File lib/finite/finite.rb, line 11 def states @states ||= StateMachine.machines[self.class].states @states end