Class: YPetri::Net::State::Feature::Marking
- Inherits:
-
YPetri::Net::State::Feature
- Object
- YPetri::Net::State::Feature
- YPetri::Net::State::Feature::Marking
- Defined in:
- lib/y_petri/net/state/feature/marking.rb
Overview
Marking of a Petri net place.
Class Attribute Summary collapse
-
.instances ⇒ Object
readonly
Returns the value of attribute instances.
Instance Attribute Summary collapse
-
#place ⇒ Object
readonly
Returns the value of attribute place.
Class Method Summary collapse
- .__new__ ⇒ Object
- .new(id) ⇒ Object
-
.of(id) ⇒ Object
Alias of #new method.
-
.parametrize(*args) ⇒ Object
Customization of the Class#parametrize method.
Instance Method Summary collapse
-
#==(other) ⇒ Object
Marking features are equal if they are of equal PS and refer to the same place.
-
#extract_from(arg, **nn) ⇒ Object
Extracts the receiver marking feature from the argument.
-
#initialize(place) ⇒ Marking
constructor
The constructor of a marking feature takes exactly one argument (place identifier).
-
#inspect ⇒ Object
Inspect string of the marking feature.
-
#label ⇒ Object
Label for the marking feature (to use in graphics etc.).
-
#to_s ⇒ Object
A string briefly describing the marking 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
#initialize(place) ⇒ Marking
The constructor of a marking feature takes exactly one argument (place identifier).
51 52 53 |
# File 'lib/y_petri/net/state/feature/marking.rb', line 51 def initialize place @place = net.place( place ) end |
Class Attribute Details
.instances ⇒ Object (readonly)
Returns the value of attribute instances.
33 34 35 |
# File 'lib/y_petri/net/state/feature/marking.rb', line 33 def instances @instances end |
Instance Attribute Details
#place ⇒ Object (readonly)
Returns the value of attribute place.
6 7 8 |
# File 'lib/y_petri/net/state/feature/marking.rb', line 6 def place @place end |
Class Method Details
.__new__ ⇒ Object
35 |
# File 'lib/y_petri/net/state/feature/marking.rb', line 35 alias __new__ new |
.new(id) ⇒ Object
37 38 39 |
# File 'lib/y_petri/net/state/feature/marking.rb', line 37 def new id instances[ id ] end |
.of(id) ⇒ Object
Alias of #new method.
43 44 45 |
# File 'lib/y_petri/net/state/feature/marking.rb', line 43 def of id new 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 |
# File 'lib/y_petri/net/state/feature/marking.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.place ] when ç.net.Place then p = begin ç.net.place id rescue TypeError => err raise TypeError, "Place #{id} not " + "present in net #{ç.net}! (#{err})" end hsh[ id ] = ç.__new__( id ) else hsh[ ç.net.place( id ) ] end end ) end end |
Instance Method Details
#==(other) ⇒ Object
Marking features are equal if they are of equal PS and refer to the same place.
94 95 96 |
# File 'lib/y_petri/net/state/feature/marking.rb', line 94 def == other other.is_a? net.State.Feature.Marking and place == other.place end |
#extract_from(arg, **nn) ⇒ Object
Extracts the receiver marking feature from the argument. This can be typically a simulation instance.
58 59 60 61 62 63 64 65 |
# File 'lib/y_petri/net/state/feature/marking.rb', line 58 def extract_from arg, **nn case arg when YPetri::Simulation then arg.m( place ).first else fail TypeError, "Argument type not supported!" end end |
#inspect ⇒ Object
Inspect string of the marking feature.
87 88 89 |
# File 'lib/y_petri/net/state/feature/marking.rb', line 87 def inspect "<Feature::Marking of #{place.name ? place.name : place}>" end |
#label ⇒ Object
Label for the marking feature (to use in graphics etc.)
81 82 83 |
# File 'lib/y_petri/net/state/feature/marking.rb', line 81 def label ":#{place.name}" end |
#to_s ⇒ Object
A string briefly describing the marking feature.
75 76 77 |
# File 'lib/y_petri/net/state/feature/marking.rb', line 75 def to_s "m:#{label}" end |
#type ⇒ Object
Type of this feature.
69 70 71 |
# File 'lib/y_petri/net/state/feature/marking.rb', line 69 def type :marking end |