Module: YPetri::Simulation::Nodes::Access

Defined in:
lib/y_petri/simulation/nodes/access.rb

Instance Method Summary collapse

Instance Method Details

#includes?(id) ⇒ Boolean Also known as: include?

Does a node belong to the simulation?

Returns:

  • (Boolean)


10
11
12
# File 'lib/y_petri/simulation/nodes/access.rb', line 10

def includes?( id )
  includes_place?( id ) || includes_transition?( id )
end

#n(node) ⇒ Object

Node of the simulation belonging to the net. Each simulation has its representations of places and transitions, which are based on the places and transitions of the underlying net. This method takes one argument, which (place, place name, transition, or transition name) and returns the corresponding node of the underlying net.



21
22
23
# File 'lib/y_petri/simulation/nodes/access.rb', line 21

def n( node )
  node( node ).source
end

#Nn(array) ⇒ Object

Nodes of the simulation (belonging to the net). Expects a single array of nodes (places / transitions) or node ids and returns an array of the corresponding nodes in the underlying net.



29
30
31
# File 'lib/y_petri/simulation/nodes/access.rb', line 29

def Nn( array )
  Nodes( array ).sources
end

#nn(*nodes) ⇒ Object

Without arguments, returns all the nodes of the underlying net. Otherwise, it accepts an arbitrary number of nodes or node ids as arguments, and returns an array of the corresponding nodes of the underlying net.



37
38
39
# File 'lib/y_petri/simulation/nodes/access.rb', line 37

def nn( *nodes )
  nodes( *nodes ).sources
end

#nnn(*nodes) ⇒ Object

Names of the simulation’s nodes. Arguments, if any, are treated analogically to the #nodes method.



44
45
46
# File 'lib/y_petri/simulation/nodes/access.rb', line 44

def nnn *nodes
  nnn( *nodes ).names
end