Sha256: bbc444c70a894dffc632776ed215c29f897850229a1815b7ca0d3b635bd165d1

Contents?: true

Size: 945 Bytes

Versions: 36

Compression:

Stored size: 945 Bytes

Contents

# encoding: utf-8

# Provides basic skeleton for dependency injection for the triples of the
# parametrized subclasses of Place, Transition and Net in different workspaces.
# 
class YPetri::World
  module Dependency
    delegate :Place, :Transition, :Net, to: :world

    # Place instance identification.
    # 
    def place id
      world.place( id )
    end

    # Transition instance identification.
    # 
    def transition id
      world.transition( id )
    end

    # Element instance identification.
    # 
    def element id
      begin
        place( id )
      rescue NameError, TypeError
        begin
          transition( id )
        rescue NameError, TypeError => err
          raise TypeError, "Unrecognized place or transition: #{element} (#{err})"
        end
      end
    end

    # Net instance identification.
    # 
    def net id
      Net().instance( id )
    end
  end # module Dependency
end # module YPetri::World

Version data entries

36 entries across 36 versions & 1 rubygems

Version Path
y_petri-2.2.4 lib/y_petri/world/dependency.rb
y_petri-2.2.3 lib/y_petri/world/dependency.rb
y_petri-2.2.2 lib/y_petri/world/dependency.rb
y_petri-2.2.1 lib/y_petri/world/dependency.rb
y_petri-2.2.0 lib/y_petri/world/dependency.rb
y_petri-2.1.51 lib/y_petri/world/dependency.rb
y_petri-2.1.50 lib/y_petri/world/dependency.rb
y_petri-2.1.49 lib/y_petri/world/dependency.rb
y_petri-2.1.48 lib/y_petri/world/dependency.rb
y_petri-2.1.47 lib/y_petri/world/dependency.rb
y_petri-2.1.46 lib/y_petri/world/dependency.rb
y_petri-2.1.45 lib/y_petri/world/dependency.rb
y_petri-2.1.44 lib/y_petri/world/dependency.rb
y_petri-2.1.42 lib/y_petri/world/dependency.rb
y_petri-2.1.40 lib/y_petri/world/dependency.rb
y_petri-2.1.39 lib/y_petri/world/dependency.rb
y_petri-2.1.37 lib/y_petri/world/dependency.rb
y_petri-2.1.36 lib/y_petri/world/dependency.rb
y_petri-2.1.35 lib/y_petri/world/dependency.rb
y_petri-2.1.34 lib/y_petri/world/dependency.rb