Sha256: 8800f77b2ab8d579c172c0a4c6dee5f2825052633a3d3b91145fef8fc3db76a0

Contents?: true

Size: 1.58 KB

Versions: 1

Compression:

Stored size: 1.58 KB

Contents

# encoding: utf-8

class YPetri::Net::State
  class Feature
    # Flux of a Petri net TS transition.
    # 
    class Flux < Feature
      attr_reader :transition

      class << self
        def parametrize *args
          Class.instance_method( :parametrize ).bind( self ).( *args ).tap do |ç|
            ç.instance_variable_set( :@instances,
                                     Hash.new do |hsh, id|
                                       case id
                                       when Firing then
                                         hsh[ id.transition ]
                                       when ç.net.Transition then
                                         hsh[ id ] = ç.__new__( id )
                                       else
                                         hsh[ ç.net.transition( id ) ]
                                       end
                                     end )
          end
        end

        attr_reader :instances

        alias __new__ new

        def new id
          instances[ id ]
        end

        def of transition_id
          new transition_id
        end
      end

      def initialize id
        @transition = net.transition( id.is_a?( Flux ) ? id.transition : id )
      end

      def extract_from arg, **nn
        case arg
        when YPetri::Simulation then
          arg.send( :TS_transitions, [ transition ] ).flux.first
        else
          fail TypeError, "Argument type not supported!"
        end
      end

      def label
        "Φ:#{transition.name}"
      end
    end # class Flux
  end # class Feature
end # YPetri::Net::State

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
y_petri-2.1.3 lib/y_petri/net/state/feature/flux.rb