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.1.33 lib/y_petri/simulation/transitions/A.rb
y_petri-2.1.31 lib/y_petri/simulation/transitions/A.rb
y_petri-2.1.30 lib/y_petri/simulation/transitions/A.rb
y_petri-2.1.26 lib/y_petri/simulation/transitions/A.rb
y_petri-2.1.25 lib/y_petri/simulation/transitions/A.rb
y_petri-2.1.24 lib/y_petri/simulation/transitions/A.rb
y_petri-2.1.22 lib/y_petri/simulation/transitions/A.rb
y_petri-2.1.21 lib/y_petri/simulation/transitions/A.rb
y_petri-2.1.20 lib/y_petri/simulation/transitions/A.rb
y_petri-2.1.18 lib/y_petri/simulation/transitions/A.rb
y_petri-2.1.17 lib/y_petri/simulation/transitions/A.rb
y_petri-2.1.16 lib/y_petri/simulation/transitions/A.rb