Sha256: 51562cbfa855ae3d5e8c33f7dcff61a89bb232f8869b06577cc530c8b28034a8

Contents?: true

Size: 996 Bytes

Versions: 32

Compression:

Stored size: 996 Bytes

Contents

#encoding: utf-8

# A mixin for collections of A transitions.
# 
class YPetri::Simulation::Transitions
  module Type_A
    def initialize
    end

    # Assignment closures that directly affect the marking when called.
    # 
    def assignment_closures
      map &:assignment_closure
    end

    # Combined assignment action, as it would occur if these A transitions fired
    # in order, as hash place >> action.
    # 
    def action
      each_with_object Hash.new do |t, hsh| hsh.update( t.action ) end
    end

    # Returns the assignments to all places, as they would happen if A transition
    # could change their values.
    # 
    def act
      each_with_object Hash.new do |t, hsh| hsh.update( t.act ) end
    end

    # Builds a joint assignment closure.
    # 
    def to_assignment_closure
      closures = assignment_closures
      -> { closures.each &:call }
    end
    alias assignment_closure to_assignment_closure
  end # Type_A
end # class YPetri::Simulation::Transitions

Version data entries

32 entries across 32 versions & 1 rubygems

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