module Gdsii::Access::EnumerableGroup

Mix in methods that work with a predefined @list attribute. The list is made Enumerable and a number of methods are mixed in. Used in Properties, Structure, and Library.

Public Instance Methods

add(object) click to toggle source

Add an object to this list as either an object instance or as the object data. Similar to Array#push but validates the data being added. The object added is returned.

# File lib/gdsii/mixins.rb, line 224
def add(object)
  self.validate_addition(object) if self.respond_to?(:validate_addition)
  @list.push object
  object
end
each() { |e| ... } click to toggle source

Loops through each object yielding along the way.

# File lib/gdsii/mixins.rb, line 217
def each(); @list.each {|e| yield e}; end
list() click to toggle source

Get the list object.

# File lib/gdsii/mixins.rb, line 210
def list() @list; end
Also aliased as: to_a
method_missing(method_sym, *args) click to toggle source

Implement a trap for a method that might be missing. Any method not listed here will default to the @list Array attribute if @list respond_to? the method. This nifty feature allows us to “inherit” all methods related Array which will be operated upon the @list Array attribute.

Calls superclass method
# File lib/gdsii/mixins.rb, line 245
def method_missing(method_sym, *args)
  if @list.respond_to?(method_sym)
    # The array @list responds to this method - use it on @list
    @list.method(method_sym).call(*args)
  else
    # Raise the #method_missing error
    super
  end
end
remove() { |e| ... } click to toggle source

Remove object(s) from this element when the propert(y/ies) match the given criteria (in the code block). Equivalent to Array#reject!.

# File lib/gdsii/mixins.rb, line 234
def remove()
  @list.reject! {|e| yield e}
end
to_a()
Alias for: list