Module: YPetri::Net::NodeAccess
- Defined in:
- lib/y_petri/net/node_access.rb
Overview
Access to nodes (places and transitions) of a Petri net.
Instance Method Summary collapse
-
#a_transitions(*transitions) ⇒ Object
(also: #a_tt)
Expects an arbitrary number of a transitions or transition ids as arguments, and returns an array of corresponding transition instances.
-
#A_Transitions(array) ⇒ Object
Expects an array of A transitions or transition ids, and returns an array of corresponding transition instances.
-
#A_transitions(*transitions) ⇒ Object
(also: #A_tt)
Expects an arbitrary number of A transitions or transition ids as arguments, and returns an array of corresponding transition instances.
-
#a_Transitions(array) ⇒ Object
Expects an array of a transitions or transition ids, and returns an array of corresponding transition instances.
-
#include?(id) ⇒ Boolean
Inquirer whether the net includes a node.
-
#include_place?(id) ⇒ Boolean
Does the net include a place?.
-
#include_transition?(id) ⇒ Boolean
Does the net include a transition?.
-
#node(id) ⇒ Object
Returns the net’s node identified by the argument.
-
#Nodes(array) ⇒ Object
Expects an array of nodes (places/transitions) or node ids, and returns an array of corresponding node instances.
-
#nodes(*nodes) ⇒ Object
(also: #nn)
Expects an arbitrary number of nodes (places/transitions) or node ids and returns an array of corresponding node instances.
-
#place(id) ⇒ Object
Returns the net’s place identified by the argument.
-
#Places(array) ⇒ Object
Expects an array of places or place ids, and returns an array of corresponding place instances.
-
#places(*places) ⇒ Object
(also: #pp)
Expects an arbitrary number of places or place ids and returns an array of corresponding place instances.
-
#S_Transitions(array) ⇒ Object
Expects an array of S transitions or transition ids, and returns an array of corresponding transition instances.
-
#S_transitions(*transitions) ⇒ Object
(also: #S_tt)
Expects an arbitrary number of S transitions or transition ids as arguments, and returns an array of corresponding transition instances.
-
#s_Transitions(array) ⇒ Object
Expects an array of s transitions or transition ids, and returns an array of corresponding transition instances.
-
#s_transitions(*transitions) ⇒ Object
(also: #s_tt)
Expects an arbitrary number of s transitions or transition ids as arguments, and returns an array of corresponding transition instances.
-
#T_transitions(*transitions) ⇒ Object
(also: #T_tt)
Expects an arbitrary number of T transitions or transition ids as arguments, and returns an array of corresponding transition instances.
-
#t_Transitions(array) ⇒ Object
Expects an array of t transitions or transition ids, and returns an array of corresponding transition instances.
-
#t_transitions(*transitions) ⇒ Object
(also: #t_tt)
Expects an arbitrary number of t transitions or transition ids as arguments, and returns an array of corresponding transition instances.
-
#T_Transitions(array) ⇒ Object
Expects an array of T transitions or transition ids, and returns an array of corresponding transition instances.
-
#transition(id) ⇒ Object
Returns the net’s transition identified by the argument.
-
#Transitions(array) ⇒ Object
Expects an array of transitions or transition ids, and returns an array of corresponding transition instances.
-
#transitions(*transitions) ⇒ Object
(also: #tt)
Expects an arbitrary number of transitions or transition ids and returns an array of corresponding transition instances.
-
#TS_Transitions(array) ⇒ Object
Expects an array of TS transitions or transition ids, and returns an array of corresponding transition instances.
-
#Ts_Transitions(array) ⇒ Object
Expects an array of Ts transitions or transition ids, and returns an array of corresponding transition instances.
-
#tS_transitions(*transitions) ⇒ Object
(also: #tS_tt)
Expects an arbitrary number of tS transitions or transition ids as arguments, and returns an array of corresponding transition instances.
-
#Ts_transitions(*transitions) ⇒ Object
(also: #Ts_tt)
Expects an arbitrary number of Ts transitions or transition ids as arguments, and returns an array of corresponding transition instances.
-
#TS_transitions(*transitions) ⇒ Object
(also: #TS_tt)
Expects an arbitrary number of TS transitions or transition ids as arguments, and returns an array of corresponding transition instances.
-
#ts_Transitions(array) ⇒ Object
Expects an array of ts transitions or transition ids, and returns an array of corresponding transition instances.
-
#ts_transitions(*transitions) ⇒ Object
(also: #ts_tt)
Expects an arbitrary number of ts transitions or transition ids as arguments, and returns an array of corresponding transition instances.
-
#tS_Transitions(array) ⇒ Object
Expects an array of tS transitions or transition ids, and returns an array of corresponding transition instances.
Instance Method Details
#a_transitions(*transitions) ⇒ Object Also known as: a_tt
Expects an arbitrary number of a transitions or transition ids as arguments, and returns an array of corresponding transition instances.
194 195 196 197 |
# File 'lib/y_petri/net/node_access.rb', line 194 def a_transitions *transitions return transitions().select &:a? if transitions.empty? a_Transitions( transitions ) end |
#A_Transitions(array) ⇒ Object
Expects an array of A transitions or transition ids, and returns an array of corresponding transition instances.
171 172 173 |
# File 'lib/y_petri/net/node_access.rb', line 171 def A_Transitions array Transitions( array ).aT_all "transition identifiers", "be A", &:A? end |
#A_transitions(*transitions) ⇒ Object Also known as: A_tt
Expects an arbitrary number of A transitions or transition ids as arguments, and returns an array of corresponding transition instances.
178 179 180 181 |
# File 'lib/y_petri/net/node_access.rb', line 178 def A_transitions *transitions return transitions().select &:A? if transitions.empty? A_Transitions( transitions ) end |
#a_Transitions(array) ⇒ Object
Expects an array of a transitions or transition ids, and returns an array of corresponding transition instances.
187 188 189 |
# File 'lib/y_petri/net/node_access.rb', line 187 def a_Transitions array Transitions( array ).aT_all "transition identifiers", "be a", &:a? end |
#include?(id) ⇒ Boolean
Inquirer whether the net includes a node.
20 21 22 |
# File 'lib/y_petri/net/node_access.rb', line 20 def include? id include_place?( id ) || include_transition?( id ) end |
#include_place?(id) ⇒ Boolean
Does the net include a place?
6 7 8 9 10 |
# File 'lib/y_petri/net/node_access.rb', line 6 def include_place? id begin place( id ) and true rescue NameError, TypeError; false end end |
#include_transition?(id) ⇒ Boolean
Does the net include a transition?
14 15 16 |
# File 'lib/y_petri/net/node_access.rb', line 14 def include_transition? id begin; transition( id ) and true; rescue NameError, TypeError; false end end |
#node(id) ⇒ Object
Returns the net’s node identified by the argument
42 43 44 45 46 47 48 49 50 51 |
# File 'lib/y_petri/net/node_access.rb', line 42 def node id begin; place( id ); rescue NameError, TypeError begin; transition( id ); rescue NameError, TypeError puts "Hello from failed #node, id is:" puts id p id raise TypeError, "The net does not include place/transition #{id}!" end end end |
#Nodes(array) ⇒ Object
Expects an array of nodes (places/transitions) or node ids, and returns an array of corresponding node instances.
56 57 58 |
# File 'lib/y_petri/net/node_access.rb', line 56 def Nodes array array.map &method( :node ) end |
#nodes(*nodes) ⇒ Object Also known as: nn
Expects an arbitrary number of nodes (places/transitions) or node ids and returns an array of corresponding node instances. If no arguments are supplied, returns all the nodes.
64 65 66 67 |
# File 'lib/y_petri/net/node_access.rb', line 64 def nodes *nodes return @places + @transitions if nodes.empty? Nodes( nodes ) end |
#place(id) ⇒ Object
Returns the net’s place identified by the argument.
26 27 28 29 30 |
# File 'lib/y_petri/net/node_access.rb', line 26 def place id ( super rescue Place().instance( id ) ).tap do |p| fail TypeError, "No place #{id} in the net!" unless places.include? p end end |
#Places(array) ⇒ Object
Expects an array of places or place ids, and returns an array of corresponding place instances.
73 74 75 |
# File 'lib/y_petri/net/node_access.rb', line 73 def Places array array.map &method( :place ) end |
#places(*places) ⇒ Object Also known as: pp
Expects an arbitrary number of places or place ids and returns an array of corresponding place instances. If no arguments are supplied, returns all net’s places.
81 82 83 84 |
# File 'lib/y_petri/net/node_access.rb', line 81 def places *places return @places.dup if places.empty? Places( places ) end |
#S_Transitions(array) ⇒ Object
Expects an array of S transitions or transition ids, and returns an array of corresponding transition instances.
203 204 205 |
# File 'lib/y_petri/net/node_access.rb', line 203 def S_Transitions array Transitions( array ).aT_all "transition identifiers", "be S", &:S? end |
#S_transitions(*transitions) ⇒ Object Also known as: S_tt
Expects an arbitrary number of S transitions or transition ids as arguments, and returns an array of corresponding transition instances.
210 211 212 213 |
# File 'lib/y_petri/net/node_access.rb', line 210 def S_transitions *transitions return transitions().select &:S? if transitions.empty? S_Transitions( transitions ) end |
#s_Transitions(array) ⇒ Object
Expects an array of s transitions or transition ids, and returns an array of corresponding transition instances.
219 220 221 |
# File 'lib/y_petri/net/node_access.rb', line 219 def s_Transitions array Transitions( array ).aT_all "transition identifiers", "be s", &:s? end |
#s_transitions(*transitions) ⇒ Object Also known as: s_tt
Expects an arbitrary number of s transitions or transition ids as arguments, and returns an array of corresponding transition instances.
226 227 228 229 |
# File 'lib/y_petri/net/node_access.rb', line 226 def s_transitions *transitions return transitions().select &:s? if transitions.empty? s_Transitions( transitions ) end |
#T_transitions(*transitions) ⇒ Object Also known as: T_tt
Expects an arbitrary number of T transitions or transition ids as arguments, and returns an array of corresponding transition instances.
242 243 244 245 |
# File 'lib/y_petri/net/node_access.rb', line 242 def T_transitions *transitions return transitions().select &:T? if transitions.empty? T_Transitions( transitions ) end |
#t_Transitions(array) ⇒ Object
Expects an array of t transitions or transition ids, and returns an array of corresponding transition instances.
251 252 253 |
# File 'lib/y_petri/net/node_access.rb', line 251 def t_Transitions array Transitions( array ).aT_all "transition identifiers", "be t", &:t? end |
#t_transitions(*transitions) ⇒ Object Also known as: t_tt
Expects an arbitrary number of t transitions or transition ids as arguments, and returns an array of corresponding transition instances.
258 259 260 261 |
# File 'lib/y_petri/net/node_access.rb', line 258 def t_transitions *transitions return transitions().select &:t? if transitions.empty? t_Transitions( transitions ) end |
#T_Transitions(array) ⇒ Object
Expects an array of T transitions or transition ids, and returns an array of corresponding transition instances.
235 236 237 |
# File 'lib/y_petri/net/node_access.rb', line 235 def T_Transitions array Transitions( array ).aT_all "transition identifiers", "be T", &:T? end |
#transition(id) ⇒ Object
Returns the net’s transition identified by the argument.
34 35 36 37 38 |
# File 'lib/y_petri/net/node_access.rb', line 34 def transition id ( super rescue Transition().instance( id ) ).tap do |t| transitions.include? t or fail TypeError, "No transition #{id} in the net!" end end |
#Transitions(array) ⇒ Object
Expects an array of transitions or transition ids, and returns an array of corresponding transition instances.
90 91 92 |
# File 'lib/y_petri/net/node_access.rb', line 90 def Transitions array array.map &method( :transition ) end |
#transitions(*transitions) ⇒ Object Also known as: tt
Expects an arbitrary number of transitions or transition ids and returns an array of corresponding transition instances. If no arguments are supplied, returns all net’s transitions.
98 99 100 101 |
# File 'lib/y_petri/net/node_access.rb', line 98 def transitions *transitions return @transitions.dup if transitions.empty? Transitions( transitions ) end |
#TS_Transitions(array) ⇒ Object
Expects an array of TS transitions or transition ids, and returns an array of corresponding transition instances.
155 156 157 |
# File 'lib/y_petri/net/node_access.rb', line 155 def TS_Transitions array Transitions( array ).aT_all "transition identifiers", "be TS", &:TS? end |
#Ts_Transitions(array) ⇒ Object
Expects an array of Ts transitions or transition ids, and returns an array of corresponding transition instances.
139 140 141 |
# File 'lib/y_petri/net/node_access.rb', line 139 def Ts_Transitions array Transitions( array ).aT_all "transition identifiers", "be Ts", &:Ts? end |
#tS_transitions(*transitions) ⇒ Object Also known as: tS_tt
Expects an arbitrary number of tS transitions or transition ids as arguments, and returns an array of corresponding transition instances.
130 131 132 133 |
# File 'lib/y_petri/net/node_access.rb', line 130 def tS_transitions *transitions return transitions().select &:tS? if transitions.empty? tS_Transitions( transitions ) end |
#Ts_transitions(*transitions) ⇒ Object Also known as: Ts_tt
Expects an arbitrary number of Ts transitions or transition ids as arguments, and returns an array of corresponding transition instances.
146 147 148 149 |
# File 'lib/y_petri/net/node_access.rb', line 146 def Ts_transitions *transitions return transitions().select &:Ts? if transitions.empty? Ts_Transitions( transitions ) end |
#TS_transitions(*transitions) ⇒ Object Also known as: TS_tt
Expects an arbitrary number of TS transitions or transition ids as arguments, and returns an array of corresponding transition instances.
162 163 164 165 |
# File 'lib/y_petri/net/node_access.rb', line 162 def TS_transitions *transitions return transitions().select &:TS? if transitions.empty? TS_Transitions( transitions ) end |
#ts_Transitions(array) ⇒ Object
Expects an array of ts transitions or transition ids, and returns an array of corresponding transition instances.
107 108 109 |
# File 'lib/y_petri/net/node_access.rb', line 107 def ts_Transitions array Transitions( array ).aT_all "transition identifiers", "be ts", &:ts? end |
#ts_transitions(*transitions) ⇒ Object Also known as: ts_tt
Expects an arbitrary number of ts transitions or transition ids as arguments, and returns an array of corresponding transition instances.
114 115 116 117 |
# File 'lib/y_petri/net/node_access.rb', line 114 def ts_transitions *transitions return transitions().select &:ts? if transitions.empty? ts_Transitions( transitions ) end |
#tS_Transitions(array) ⇒ Object
Expects an array of tS transitions or transition ids, and returns an array of corresponding transition instances.
123 124 125 |
# File 'lib/y_petri/net/node_access.rb', line 123 def tS_Transitions array Transitions( array ).aT_all "transition identifiers", "be tS", &:tS? end |