Module: YPetri::Transition::Arcs
- Defined in:
- lib/y_petri/transition/arcs.rb
Overview
Connectivity aspect of a transition.
Instance Method Summary collapse
-
#aa(arg = nil) ⇒ Object
Names of the places connected to the transition.
-
#arc(id) ⇒ Object
Arc (a place connected to this transition) identifier.
-
#arcs ⇒ Object
Union of action arcs and test arcs.
-
#codomain_marking ⇒ Object
Marking of the codomain places.
-
#codomain_pp ⇒ Object
(also: #downstream_pp)
Names of downstream places.
-
#domain_marking ⇒ Object
Marking of the domain places.
-
#domain_pp ⇒ Object
(also: #upstream_pp)
Names of upstream places.
-
#fire_downstream_recursively ⇒ Object
Recursive firing of the downstream net portion (honors #cocked?).
-
#fire_upstream_recursively ⇒ Object
Recursive firing of the upstream net portion (honors #cocked?).
Instance Method Details
#aa(arg = nil) ⇒ Object
Names of the places connected to the transition. The optional argument controls what is returned for unnamed instances, and works just like in Array#names
method from y_support/name_magic
: The default value (nil) returns nil, true returns the instance itself, and false drops the unnamed instances from the list altogether.
28 29 30 |
# File 'lib/y_petri/transition/arcs.rb', line 28 def aa arg=nil arcs.names arg end |
#arc(id) ⇒ Object
Arc (a place connected to this transition) identifier.
34 35 36 37 38 |
# File 'lib/y_petri/transition/arcs.rb', line 34 def arc id place = place( id ) arcs.find { |p| p == place } or fail TypeError, "No place #{id} connected to #{self}!" end |
#arcs ⇒ Object
Union of action arcs and test arcs.
18 19 20 |
# File 'lib/y_petri/transition/arcs.rb', line 18 def arcs domain | codomain end |
#codomain_marking ⇒ Object
Marking of the codomain places.
46 |
# File 'lib/y_petri/transition/arcs.rb', line 46 def codomain_marking; codomain.map &:marking end |
#codomain_pp ⇒ Object Also known as: downstream_pp
Names of downstream places.
13 |
# File 'lib/y_petri/transition/arcs.rb', line 13 def codomain_pp; codomain.map { |p| p.name || p.object_id } end |
#domain_marking ⇒ Object
Marking of the domain places.
42 |
# File 'lib/y_petri/transition/arcs.rb', line 42 def domain_marking; domain.map &:marking end |
#domain_pp ⇒ Object Also known as: upstream_pp
Names of upstream places.
8 |
# File 'lib/y_petri/transition/arcs.rb', line 8 def domain_pp; domain.map { |p| p.name || p.object_id } end |
#fire_downstream_recursively ⇒ Object
Recursive firing of the downstream net portion (honors #cocked?).
60 61 62 63 64 65 66 |
# File 'lib/y_petri/transition/arcs.rb', line 60 def fire_downstream_recursively return false unless cocked? uncock fire! downstream_places.each &:fire_downstream_recursively return true end |
#fire_upstream_recursively ⇒ Object
Recursive firing of the upstream net portion (honors #cocked?).
50 51 52 53 54 55 56 |
# File 'lib/y_petri/transition/arcs.rb', line 50 def fire_upstream_recursively return false unless cocked? uncock upstream_places.each &:fire_upstream_recursively fire! return true end |