module YPetri::World::PetriNetAspect

Workspace instance methods related to the Petri net aspect of YPetri (places, transitions, net instances).

Public Class Methods

new() click to toggle source

Instance initialization.

Calls superclass method
# File lib/y_petri/world/petri_net_aspect.rb, line 9
def initialize
  set_up_Top_net # Sets up :Top net encompassing all places and transitions.
  super
end

Public Instance Methods

net( id ) click to toggle source

Returns a net instance identified by the argument.

# File lib/y_petri/world/petri_net_aspect.rb, line 28
def net( id )
  Net().instance( id )
end
nets() click to toggle source

Net instances.

# File lib/y_petri/world/petri_net_aspect.rb, line 46
def nets
  Net().instances
end
place( id ) click to toggle source

Returns a place instance identified by the argument.

# File lib/y_petri/world/petri_net_aspect.rb, line 16
def place( id )
  Place().instance( id )
end
places() click to toggle source

Place instances.

# File lib/y_petri/world/petri_net_aspect.rb, line 34
def places
  Place().instances
end
transition( id ) click to toggle source

Returns a transition instance identified by the argument.

# File lib/y_petri/world/petri_net_aspect.rb, line 22
def transition( id )
  Transition().instance( id )
end
transitions() click to toggle source

Transition instances.

# File lib/y_petri/world/petri_net_aspect.rb, line 40
def transitions
  Transition().instances
end

Private Instance Methods

set_up_Top_net() click to toggle source

Creates all-encompassing Net instance named :Top.

# File lib/y_petri/world/petri_net_aspect.rb, line 54
def set_up_Top_net
  Net().send :new, name: :Top # all-encompassing :Top net
  # Hook new places to add themselves magically to the :Top net.
  Place().new_instance_hook { |new_inst| net( :Top ) << new_inst }
  # Hook new transitions to add themselves magically to the :Top net.
  Transition().new_instance_hook { |new_inst| net( :Top ) << new_inst }
end