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 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
Loops through each object yielding along the way.
# File lib/gdsii/mixins.rb, line 217 def each(); @list.each {|e| yield e}; end
Get the list object.
# File lib/gdsii/mixins.rb, line 210 def list() @list; end
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.
# 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 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