Sha256: e95919a580d401eab50cdb79e6dba1e2eb1feff326839e130cac111588dfa853
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
# encoding: utf-8 # Basic elements of a simulation, a mixin intended for YPetri::Simulation. # class YPetri::Simulation class Elements < Array ★ Dependency class << self # New collection constructor # def load collection new.tap { |inst| inst.load collection } end end delegate :simulation, to: "self.class" # Loads elements to this collection. # def load elements elements.each{ |e| push e } end # Creates a subset of this collection (of the same class). # def subset element_ids=nil, &block if block_given? then msg = "If block is given, arguments are not allowed!" fail ArgumentError, msg unless element_ids.nil? self.class.load select( &block ) else ee = elements( element_ids ) ee.all? { |e| include? e } or fail TypeError, "All subset elements must be in the collection." self.class.load( ee ) end end # Returns an array of the element sources (elemens in the original net). # def sources map &:source end alias to_sources sources end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
y_petri-2.1.12 | lib/y_petri/simulation/elements.rb |
y_petri-2.1.11 | lib/y_petri/simulation/elements.rb |