Class: YPetri::Net::State::Feature::Flux
- Inherits:
-
YPetri::Net::State::Feature
- Object
- YPetri::Net::State::Feature
- YPetri::Net::State::Feature::Flux
- Defined in:
- lib/y_petri/net/state/feature/flux.rb
Overview
Flux of a Petri net TS transition.
Class Attribute Summary collapse
-
.instances ⇒ Object
readonly
Returns the value of attribute instances.
Instance Attribute Summary collapse
-
#transition ⇒ Object
readonly
Returns the value of attribute transition.
Class Method Summary collapse
- .__new__ ⇒ Object
- .new(id) ⇒ Object
-
.of(transition_id) ⇒ Object
Alias of #new method.
-
.parametrize(*args) ⇒ Object
Customization of the Class#parametrize method.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Flux features are equal if they are of equal PS and refer to the same transition.
-
#extract_from(arg, **nn) ⇒ Object
Extracts the receiver marking feature from the argument.
-
#initialize(id) ⇒ Flux
constructor
The constructor of a marking feature takes exactly one argument (transition identifier).
-
#inspect ⇒ Object
Inspect string of the flux feature.
-
#label ⇒ Object
Label for the flux feature (to use in the graphics etc.).
-
#to_s ⇒ Object
A string briefly describing the flux feature.
-
#type ⇒ Object
Type of this feature.
Methods inherited from YPetri::Net::State::Feature
#%, Assignment, Delta, Firing, Flux, Gradient, Marking, infer_from_node
Constructor Details
Class Attribute Details
.instances ⇒ Object (readonly)
Returns the value of attribute instances.
35 36 37 |
# File 'lib/y_petri/net/state/feature/flux.rb', line 35 def instances @instances end |
Instance Attribute Details
#transition ⇒ Object (readonly)
Returns the value of attribute transition.
6 7 8 |
# File 'lib/y_petri/net/state/feature/flux.rb', line 6 def transition @transition end |
Class Method Details
.__new__ ⇒ Object
37 |
# File 'lib/y_petri/net/state/feature/flux.rb', line 37 alias __new__ new |
.new(id) ⇒ Object
39 40 41 |
# File 'lib/y_petri/net/state/feature/flux.rb', line 39 def new id instances[ id ] end |
.of(transition_id) ⇒ Object
Alias of #new method.
45 46 47 |
# File 'lib/y_petri/net/state/feature/flux.rb', line 45 def of transition_id new transition_id end |
.parametrize(*args) ⇒ Object
Customization of the Class#parametrize method.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/y_petri/net/state/feature/flux.rb', line 11 def parametrize *args Class.instance_method( :parametrize ).bind( self ).( *args ).tap do |ç| ç.instance_variable_set( :@instances, Hash.new do |hsh, id| case id when self then hsh[ id.transition ] when ç.net.Transition then t = begin ç.net.TS_transitions( id ).first rescue TypeError => err msg = "Transition #{id} not " + "recognized as TS transition in " + "net #{ç.net}! (%s)" raise TypeError, msg % err end hsh[ id ] = ç.__new__( t ) else hsh[ ç.net.transition( id ) ] end end ) end end |
Instance Method Details
#==(other) ⇒ Object
Flux features are equal if they are of equal PS and refer to the same transition.
96 97 98 |
# File 'lib/y_petri/net/state/feature/flux.rb', line 96 def == other other.is_a? net.State.Feature.Flux and transition == other.transition end |
#extract_from(arg, **nn) ⇒ Object
Extracts the receiver marking feature from the argument. This can be typically a simulation instance.
60 61 62 63 64 65 66 67 |
# File 'lib/y_petri/net/state/feature/flux.rb', line 60 def extract_from arg, **nn case arg when YPetri::Simulation then arg.send( :TS_transitions, transition ).first.flux else fail TypeError, "Argument type not supported!" end end |
#inspect ⇒ Object
Inspect string of the flux feature.
89 90 91 |
# File 'lib/y_petri/net/state/feature/flux.rb', line 89 def inspect "<Feature::Flux of #{transition.name ? transition.name : transition}>" end |
#label ⇒ Object
Label for the flux feature (to use in the graphics etc.)
83 84 85 |
# File 'lib/y_petri/net/state/feature/flux.rb', line 83 def label "Φ:#{transition.name}" end |
#to_s ⇒ Object
A string briefly describing the flux feature.
77 78 79 |
# File 'lib/y_petri/net/state/feature/flux.rb', line 77 def to_s label end |
#type ⇒ Object
Type of this feature.
71 72 73 |
# File 'lib/y_petri/net/state/feature/flux.rb', line 71 def type :flux end |