Sha256: a14662e7936545e0a0deb6d96db31fd9a5b7ae0ae24d26507ff3c22cf0f8ebb1
Contents?: true
Size: 1.49 KB
Versions: 7
Compression:
Stored size: 1.49 KB
Contents
# encoding: utf-8 # Manages the initial marking of a simulation. # class YPetri::Simulation class PlaceMapping < Hash ★ Dependency class << self # Initializes the initial marking from a hash. # def load hash new.tap do |inst| hash.with_values do |v| v = v.marking if v.is_a? YPetri::Place if v.is_a? Proc then v.call else v end end.tap &inst.method( :load ) end end end delegate :simulation, to: "self.class" alias places keys # Returns the initial marking as a column vector. # def vector simulation.MarkingVector[ *self ] end alias to_marking_vector vector # Sets the mapping value for a given place to a given value. # def set place_id, to: (fail ArgumentError, "No :to value!") update place( place_id ) => to end # Loads initial the mappings from a hash places >> values. # def load( hash ) hash.each { |place, value| set place, to: value } end # Fetches the value for a place. # def fetch place_id super place( place_id ) end # Deletes the value for a place. # def delete place_id super place( place_id ) end # Returns a hash, whose keys have been replaced with source places of # the place representations in this place mapping. # def keys_to_source_places with_keys do |key| key.source end end end # class PlaceMapping end # class YPetri::Simulation
Version data entries
7 entries across 7 versions & 1 rubygems