Sha256: 6e2b3581bd12e9571ecb3421dc4fbdbdff5845f18241f4da542383e2fac17675

Contents?: true

Size: 1.19 KB

Versions: 5

Compression:

Stored size: 1.19 KB

Contents

#encoding: utf-8

require_relative 'a'
require_relative 'A'
require_relative 't'
require_relative 'T'
require_relative 's'
require_relative 'S'
require_relative 'ts'
require_relative 'Ts'
require_relative 'tS'
require_relative 'TS'

# A mixin with transition types.
# 
class YPetri::Simulation::TransitionRepresentation
  module Types
    attr_reader :type

    def type_init *args
      extend case source.type
             when :A then Type_A
             when :TS then Type_TS
             when :Ts then Type_Ts
             when :tS then Type_tS
             when :ts then Type_ts
             else fail TypeError, "Unknown tr. type #{source.type}!" end
      init
    end
    
    # The transition's type.
    # 
    def type
      return :A if A?
      if T? then S? ? :TS : :Ts else S? ? :tS : :ts end
    end
    
    # Is this a TS transition?
    # 
    def TS?
      type == :TS
    end
    
    # Is this a Ts transition?
    # 
    def Ts?
      type == :Ts
    end
    
    # Is this a tS transition?
    # 
    def tS?
      type == :tS
    end
    
    # Is this a ts transition?
    # 
    def ts?
      type == :ts
    end
  end # module Types
end # class YPetri::Simulation::TransitionRepresentation

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
y_petri-2.1.10 lib/y_petri/simulation/transition_representation/types.rb
y_petri-2.1.9 lib/y_petri/simulation/transition_representation/types.rb
y_petri-2.1.7 lib/y_petri/simulation/transition_representation/types.rb
y_petri-2.1.6 lib/y_petri/simulation/transition_representation/types.rb
y_petri-2.1.3 lib/y_petri/simulation/transition_representation/types.rb