class Gdsii::Group

Generic base class for a GDSII grouping of records (i.e. a boundary object and all records associated with it). This class will not be used directly but will be inherited by the various record groupings.

Attributes

records[R]

Public Class Methods

bnf_key() click to toggle source

Get the BNF key for this class (default is the instantiating class)

# File lib/gdsii/group.rb, line 92
def bnf_key(); (@bnf_key.nil?) ? self : @bnf_key ; end
bnf_key=(value) click to toggle source

Set the BNF key for this class

# File lib/gdsii/group.rb, line 89
def bnf_key=(value); @bnf_key = value; end
bnf_spec() click to toggle source

Return class bnf array

# File lib/gdsii/group.rb, line 86
def bnf_spec(); @bnf; end
bnf_spec=(value) click to toggle source

Set the class bnf array

# File lib/gdsii/group.rb, line 83
def bnf_spec=(value); @bnf = value; end
new() click to toggle source

Constructor of a generic GDSII record grouping. Not intended to be called directly but rather from subclasses which inherit this class.

# File lib/gdsii/group.rb, line 22
def initialize()
  @records = BnfRecords.new(self.class)
end

Public Instance Methods

configure() { |self| ... } click to toggle source

Simply yields itself for configuration (i.e. makes for prettier code). The object itself is returned.

# File lib/gdsii/group.rb, line 30
def configure()
  yield self
  self
end
validate() click to toggle source

Runs a code block to validate the object if the validate attribute is set. This is typically run to check record grouping integrity during read/write of GDSII files.

# File lib/gdsii/group.rb, line 71
def validate()
  if @validate
    @validate.call
  end
end
write(file, alt_bnf=nil) click to toggle source

Write the record grouping to a file. A file name as a String can be passed in which case a new file by the given name is opened in write mode ('w'). Alternatively, a file object may be passed in which case the record grouping are written to the file object. Examples (assumes “object” has been initialized and descends from this class):

object.write('mydesign.gds')

or

# Note: 'wb' is required for DOS/Windows compatibility
File.open('otherdesign.gds', 'wb') do |file|
  object.write(file)
end
# File lib/gdsii/group.rb, line 51
def write(file, alt_bnf=nil)
  # If the file specified is a string, then open it up for writing. If it
  # is a file open it for writing if it is not already open
  if file.class == String
    file = File.open(file,"wb")
  elsif file.class == File
    file = File.open(file,"wb") if file.closed?
  else
    raise TypeError, "Invalid file object given: #{file}"
  end

  # Write to file according to BNF
  @records.write(file, alt_bnf)
end