Sha256: df71aec79b94bd1cb5039a799dcc479b74e994518bdb9b6e82ecde5a24723829
Contents?: true
Size: 1.12 KB
Versions: 32
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
32 entries across 32 versions & 1 rubygems