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

new() click to toggle source

Generic element constructor. Not intended to be called directly but rather inherited and called through sub-classes such as Gdsii::Boundary.

Calls superclass method
# File lib/gdsii/element.rb, line 19
def initialize()
  super()
  @records[GRT_ENDEL] = Record.new(GRT_ENDEL)
  @records[Properties] = @properties = Properties.new
end
read(file, *args) click to toggle source
# 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
Also aliased as: read_el
read_each(file) { |group| ... } click to toggle source

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
read_el(file, *args)
Alias for: read

Public Instance Methods

add(*args) click to toggle source

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
is_aref?() click to toggle source

Returns true if this is a ARef element

# File lib/gdsii/element.rb, line 112
def is_aref?; self.class == ARef; end
is_boundary?() click to toggle source

Returns true if this is a Boundary element

# File lib/gdsii/element.rb, line 92
def is_boundary?; self.class == Boundary; end
is_box?() click to toggle source

Returns true if this is a Box element

# File lib/gdsii/element.rb, line 117
def is_box?; self.class == Box; end
is_node?() click to toggle source

Returns true if this is a Node element

# File lib/gdsii/element.rb, line 122
def is_node?; self.class == Node; end
is_path?() click to toggle source

Returns true if this is a Path element

# File lib/gdsii/element.rb, line 97
def is_path?; self.class == Path; end
is_sref?() click to toggle source

Returns true if this is a SRef element

# File lib/gdsii/element.rb, line 107
def is_sref?; self.class == SRef; end
is_text?() click to toggle source

Returns true if this is a Text element

# File lib/gdsii/element.rb, line 102
def is_text?; self.class == Text; end
properties() click to toggle source

Access the Properties object for this element

# File lib/gdsii/element.rb, line 50
def properties(); @properties; end
remove(*args) click to toggle source

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