lib/y_petri/net/state/feature/flux.rb in y_petri-2.1.16 vs lib/y_petri/net/state/feature/flux.rb in y_petri-2.1.17
- old
+ new
@@ -4,10 +4,12 @@
#
class YPetri::Net::State::Feature::Flux < YPetri::Net::State::Feature
attr_reader :transition
class << self
+ # Customization of the Class#parametrize method.
+ #
def parametrize *args
Class.instance_method( :parametrize ).bind( self ).( *args ).tap do |ç|
ç.instance_variable_set( :@instances,
Hash.new do |hsh, id|
case id
@@ -36,27 +38,49 @@
def new id
instances[ id ]
end
+ # Alias of #new method.
+ #
def of transition_id
new transition_id
end
end
+ # The constructor of a marking feature takes exactly one argument (transition
+ # identifier).
+ #
def initialize id
@transition = net.transition( id.is_a?( Flux ) ? id.transition : id )
end
+ # Extracts the receiver marking feature from the argument. This can be
+ # typically a simulation instance.
+ #
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
+ # A string briefly describing the flux feature.
+ #
+ def to_s
+ label
+ end
+
+ # Label for the flux feature (to use in the graphics etc.)
+ #
def label
"Φ:#{transition.name}"
+ end
+
+ # Inspect string of the flux feature.
+ #
+ def inspect
+ "<Feature::Flux of #{transition}>"
end
end # class YPetri::Net::State::Feature::Flux