Sha256: b02b32de1f8fbf6c41ada4d20294062030aded058c004a9c9538b8be8156e932

Contents?: true

Size: 1.32 KB

Versions: 32

Compression:

Stored size: 1.32 KB

Contents

# encoding: utf-8

# Workspace instance methods related to Petri net itsef (places, transitions,
# net instances).
# 
module YPetri::World::PetriNetRelated
  # Instance initialization.
  # 
  def initialize
    set_up_Top_net # Sets up :Top net encompassing all places and transitions.
    super
  end

  # Returns a place instance identified by the argument.
  # 
  def place( id )
    Place().instance( id )
  end

  # Returns a transition instance identified by the argument.
  # 
  def transition( id )
    Transition().instance( id )
  end

  # Returns a net instance identified by the argument.
  # 
  def net( id )
    Net().instance( id )
  end

  # Place instances.
  # 
  def places
    Place().instances
  end

  # Transition instances.
  # 
  def transitions
    Transition().instances
  end

  # Net instances.
  # 
  def nets
    Net().instances
  end

  private

  # Creates all-encompassing Net instance named :Top.
  # 
  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_closure { |new_inst| net( :Top ) << new_inst }
    # Hook new transitions to add themselves magically to the :Top net.
    Transition().new_instance_closure { |new_inst| net( :Top ) << new_inst }
  end
end # module YPetri::World::PetriNetRelated

Version data entries

32 entries across 32 versions & 1 rubygems

Version Path
y_petri-2.2.0 lib/y_petri/world/petri_net_related.rb
y_petri-2.1.51 lib/y_petri/world/petri_net_related.rb
y_petri-2.1.50 lib/y_petri/world/petri_net_related.rb
y_petri-2.1.49 lib/y_petri/world/petri_net_related.rb
y_petri-2.1.48 lib/y_petri/world/petri_net_related.rb
y_petri-2.1.47 lib/y_petri/world/petri_net_related.rb
y_petri-2.1.46 lib/y_petri/world/petri_net_related.rb
y_petri-2.1.45 lib/y_petri/world/petri_net_related.rb
y_petri-2.1.44 lib/y_petri/world/petri_net_related.rb
y_petri-2.1.42 lib/y_petri/world/petri_net_related.rb
y_petri-2.1.40 lib/y_petri/world/petri_net_related.rb
y_petri-2.1.39 lib/y_petri/world/petri_net_related.rb
y_petri-2.1.37 lib/y_petri/world/petri_net_related.rb
y_petri-2.1.36 lib/y_petri/world/petri_net_related.rb
y_petri-2.1.35 lib/y_petri/world/petri_net_related.rb
y_petri-2.1.34 lib/y_petri/world/petri_net_related.rb
y_petri-2.1.33 lib/y_petri/world/petri_net_related.rb
y_petri-2.1.31 lib/y_petri/world/petri_net_related.rb
y_petri-2.1.30 lib/y_petri/world/petri_net_related.rb
y_petri-2.1.26 lib/y_petri/world/petri_net_related.rb