lib/y_petri/transition/arcs.rb in y_petri-2.2.4 vs lib/y_petri/transition/arcs.rb in y_petri-2.3.2

- old
+ new

@@ -13,14 +13,30 @@ def codomain_pp; codomain.map { |p| p.name || p.object_id } end alias :downstream_pp :codomain_pp # Union of action arcs and test arcs. # - def arcs; domain | codomain end + def arcs + domain | codomain + end - # Returns names of the (places connected to) the transition's arcs. + # Names of the places connected to the transition. The optional argument + # controls what is returned for unnamed instances, and works just like in + # <tt>Array#names</tt> method from <tt>y_support/name_magic</tt>: + # The default value (_nil_) returns _nil_, _true_ returns the instance itself, + # and _false_ drops the unnamed instances from the list altogether. # - def aa; arcs.map { |p| p.name || p.object_id } end + def aa arg=nil + arcs.names arg + end + + # Arc (a place connected to this transition) identifier. + # + def arc id + place = place( id ) + arcs.find { |p| p == place } or + fail TypeError, "No place #{id} connected to #{self}!" + end # Marking of the domain places. # def domain_marking; domain.map &:marking end