Module: YPetri::Transition::Type_A
- Defined in:
- lib/y_petri/transition/A.rb
Overview
Mixin for the transitions with assignment action.
Instance Method Summary collapse
-
#a(simulation = world.simulation) ⇒ Object
Transition’s assignment action under current simulation.
-
#action ⇒ Object
Transition’s action (before validation).
-
#enabled? ⇒ Boolean
A transitions are always enabled.
-
#fire ⇒ Object
Applies action to the codomain, honoring cocking.
-
#fire! ⇒ Object
Assigns the action closure result to the codomain, regardless of cocking.
-
#function ⇒ Object
For assignment transitions, “function” refers to their action closure.
Instance Method Details
#a(simulation = world.simulation) ⇒ Object
Transition’s assignment action under current simulation.
46 47 48 |
# File 'lib/y_petri/transition/A.rb', line 46 def a simulation=world.simulation simulation.net.State.Feature.Assignment( self ) % simulation end |
#action ⇒ Object
Transition’s action (before validation).
14 15 16 |
# File 'lib/y_petri/transition/A.rb', line 14 def action action_closure.( *domain_marking ) end |
#enabled? ⇒ Boolean
A transitions are always enabled.
40 41 42 |
# File 'lib/y_petri/transition/A.rb', line 40 def enabled? true end |
#fire ⇒ Object
Applies action to the codomain, honoring cocking. Returns true if the transition fired, false if it wasn’t cocked.
21 22 23 |
# File 'lib/y_petri/transition/A.rb', line 21 def fire cocked?.tap { |x| ( uncock; fire! ) if x } end |
#fire! ⇒ Object
Assigns the action closure result to the codomain, regardless of cocking.
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/y_petri/transition/A.rb', line 27 def fire! act = Array( action ) fail TypeError, "Wrong output arity of the action " + "closure of #{self}" if act.size != codomain.size codomain.each_with_index { |place, index| # assigning action node no. index to place place.marking = act.fetch( index ) } return nil end |
#function ⇒ Object
For assignment transitions, “function” refers to their action closure.
8 9 10 |
# File 'lib/y_petri/transition/A.rb', line 8 def function action_closure end |