class Gdsii::Element
Generic class to be inherited by various GDSII elements (i.e. things that can be added to a Structure).
Public Class Methods
Generic element constructor. Not intended to be called directly but rather inherited and called through sub-classes such as Gdsii::Boundary.
# File lib/gdsii/element.rb, line 19 def initialize() super() @records[GRT_ENDEL] = Record.new(GRT_ENDEL) @records[Properties] = @properties = Properties.new end
# File lib/gdsii/element.rb, line 56 def Element.read(file, *args) rec = Record.peek(file) case rec.type when GRT_BOUNDARY then Boundary.read_el(file, *args) when GRT_TEXT then Text.read_el(file, *args) when GRT_PATH then Path.read_el(file, *args) when GRT_SREF then SRef.read_el(file, *args) when GRT_AREF then ARef.read_el(file, *args) when GRT_BOX then Box.read_el(file, *args) when GRT_NODE then Node.read_el(file, *args) else # end of the element, increment the counter and move on nil end end
After a Structure header has been read (see Structure#read_each_header) then elements may be processed as a file is read using Element#read_each. See Structure#read_each_header for an example.
Compare this with Structure#seek_next which also advances the file handle to the next structure but does not yield any elements (if only a file pointer advancement is needed and elements can be ignored).
# File lib/gdsii/element.rb, line 81 def Element.read_each(file) while (group = Element.read(file)) do yield group end # rip out ENDEL - TODO: make sure that it's ENDEL Record.read(file) end
Public Instance Methods
Shortcut for Gdsii::Access::EnumerableGroup#add. For example, instead of:
bnd.properties.add Property(1, 'testprop')
It could be simply:
bnd.add Property(1, 'testprop')
# File lib/gdsii/element.rb, line 34 def add(*args); properties.add(*args); end
Returns true if this is a ARef element
# File lib/gdsii/element.rb, line 112 def is_aref?; self.class == ARef; end
Returns true if this is a Boundary element
# File lib/gdsii/element.rb, line 92 def is_boundary?; self.class == Boundary; end
Returns true if this is a Box element
# File lib/gdsii/element.rb, line 117 def is_box?; self.class == Box; end
Returns true if this is a Node element
# File lib/gdsii/element.rb, line 122 def is_node?; self.class == Node; end
Returns true if this is a Path element
# File lib/gdsii/element.rb, line 97 def is_path?; self.class == Path; end
Returns true if this is a SRef element
# File lib/gdsii/element.rb, line 107 def is_sref?; self.class == SRef; end
Returns true if this is a Text element
# File lib/gdsii/element.rb, line 102 def is_text?; self.class == Text; end
Access the Properties object for this element
# File lib/gdsii/element.rb, line 50 def properties(); @properties; end
Shortcut for Gdsii::Access::EnumerableGroup#remove. For example, instead of:
bnd.properties.remove {|p| p.attr == 1}
It could be simply:
bnd.remove {|p| p.attr == 1}
# File lib/gdsii/element.rb, line 45 def remove(*args); properties.remove(*args); end