Module: YPetri::Transition::Arcs

Defined in:
lib/y_petri/transition/arcs.rb

Overview

Connectivity aspect of a transition.

Instance Method Summary collapse

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

#arcsObject

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_markingObject

Marking of the codomain places.



46
# File 'lib/y_petri/transition/arcs.rb', line 46

def codomain_marking; codomain.map &:marking end

#codomain_ppObject 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_markingObject

Marking of the domain places.



42
# File 'lib/y_petri/transition/arcs.rb', line 42

def domain_marking; domain.map &:marking end

#domain_ppObject 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_recursivelyObject

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_recursivelyObject

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