Class: YPetri::Net::State::Feature

Inherits:
Object
  • Object
show all
Defined in:
lib/y_petri/net/state/feature.rb

Overview

A feature of a Petri net.

Direct Known Subclasses

Delta, Firing, Flux, Gradient, Marking

Defined Under Namespace

Classes: Delta, Firing, Flux, Gradient, Marking

Class Method Summary collapse

Class Method Details

.Delta(id = L!, , transitions: net.tt) ⇒ Object



67
68
69
70
71
72
73
74
# File 'lib/y_petri/net/state/feature.rb', line 67

def Delta id=L!, transitions: net.tt
  return @Delta if id.local_object?
  case id
  when Delta() then id
  when Delta then
    Delta().of( id.place, transitions: id.transitions )
  else Delta().of( id, transitions: transitions ) end # assume it's a place
end

.Firing(id = L! ) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/y_petri/net/state/feature.rb', line 38

def Firing id=L!
  return @Firing if id.local_object?
  case id
  when Firing() then id
  when Firing then Firing().of( id.transition )
  else Firing().of( id ) end # assume it's a place
end

.Flux(id = L! ) ⇒ Object



57
58
59
60
61
62
63
64
65
# File 'lib/y_petri/net/state/feature.rb', line 57

def Flux id=L!
  return @Flux if id.local_object?
  case id
  when Flux() then id
  when Flux then Flux().of( id.transition )
  else
    Flux().of( id )
  end # assume it's a place
end

.Gradient(id = L!, , transitions: net.T_tt) ⇒ Object



46
47
48
49
50
51
52
53
54
55
# File 'lib/y_petri/net/state/feature.rb', line 46

def Gradient id=L!, transitions: net.T_tt
  return @Gradient if id.local_object?
  case id
  when Gradient() then id
  when Gradient then
    Gradient().of( id.place, transitions: id.transitions )
  else
    Gradient().of( id, transitions: transitions )
  end # assume it's a place
end

.Marking(id = L! ) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/y_petri/net/state/feature.rb', line 30

def Marking id=L!
  return @Marking if id.local_object?
  case id
  when Marking() then id
  when Marking then Marking().of( id.place )
  else Marking().of( id ) end # assume it's a place
end

.parametrize(parameters) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/y_petri/net/state/feature.rb', line 13

def parametrize parameters
  Class.new( self ).tap do |ç|
    parameters.each_pair do |ß, val|
      ç.define_singleton_method ß do val end
    end
     = ç.State
    ç.instance_variable_set :@Marking, Marking.parametrize( State:  )
    ç.instance_variable_set :@Firing, Firing.parametrize( State:  )
    ç.instance_variable_set :@Gradient, Gradient.parametrize( State:  )
    ç.instance_variable_set :@Flux, Flux.parametrize( State:  )
    ç.instance_variable_set :@Delta, Delta.parametrize( State:  )
  end
end