class Gdsii::Path

Represents a GDSII Path element. Most methods are from Element or from the various included Access module methods.

Public Class Methods

new(layer=nil, datatype=nil, pathtype=nil, width=nil, xy=nil) { |self| ... } click to toggle source

Generic method to create a path given a layer, datatype, pathtype, width, and series of alternating x/y coordinates. The default pathtype is 0.

path = Gdsii::Path.new(1, 0, 0, 100, [0,0, 1000,0, 1000,1000])
Calls superclass method Gdsii::Element.new
# File lib/gdsii/path.rb, line 49
def initialize(layer=nil, datatype=nil, pathtype=nil, width=nil, xy=nil)
  super()
  @records[GRT_PATH] = Record.new(GRT_PATH)
  self.layer = layer unless layer.nil?
  self.datatype = datatype unless datatype.nil?
  self.pathtype = (pathtype.nil?) ? 0 : pathtype
  self.width = width unless width.nil?
  self.xy = xy unless xy.nil?

  # Set a code block to validate a path record
  @validate = proc {
    # Check for begin/end extensions for pathtype == 4
    if self.pathtype == 4
      unless self.bgnextn and self.endextn
        raise "Begin/end extensions (#bgnextn= and #endextn=) required for path type 4"
      end
    end
  }

  yield self if block_given?
end
new0(layer=nil, datatype=nil, width=nil, xy=nil) { |p| ... } click to toggle source

Creates a path of type 0

# File lib/gdsii/path.rb, line 74
def Path.new0(layer=nil, datatype=nil, width=nil, xy=nil)
  Path.new(layer, datatype, 0, width, xy) {|p| yield p if block_given?}
end
new1(layer=nil, datatype=nil, width=nil, xy=nil) { |p| ... } click to toggle source

Creates a path of type 1

# File lib/gdsii/path.rb, line 81
def Path.new1(layer=nil, datatype=nil, width=nil, xy=nil)
  Path.new(layer, datatype, 1, width, xy) {|p| yield p if block_given?}
end
new2(layer=nil, datatype=nil, width=nil, xy=nil) { |p| ... } click to toggle source

Creates a path of type 2

# File lib/gdsii/path.rb, line 88
def Path.new2(layer=nil, datatype=nil, width=nil, xy=nil)
  Path.new(layer, datatype, 2, width, xy) {|p| yield p if block_given?}
end
new4(layer=nil, datatype=nil, width=nil, bgnextn=nil, endextn=nil, xy=nil) { |self| ... } click to toggle source

Creates a path of type 4; accepts begin/end extension values

path = Path.new4(1, 0, 100, 30, 30, [0,0, 1000,0, 1000,1000])
# File lib/gdsii/path.rb, line 97
def Path.new4(layer=nil, datatype=nil, width=nil,
              bgnextn=nil, endextn=nil, xy=nil)
  Path.new(layer, datatype, 4, width, xy) do |path|
    path.bgnextn = bgnextn
    path.endextn = endextn
    yield self if block_given?
  end
end

Public Instance Methods

bgnextn() click to toggle source

Get the beginning extension for path type 4 (as Fixnum). Value is in database units.

# File lib/gdsii/path.rb, line 122
def bgnextn(); @records.get_data(GRT_BGNEXTN); end
bgnextn=(val) click to toggle source

Set the beginning extension for path type 4 (as Fixnum). Value is in database units.

# File lib/gdsii/path.rb, line 113
def bgnextn=(val)
  ensure_pathtype_4
  @records.set(GRT_BGNEXTN, val)
end
bgnextn_record() click to toggle source

Get the beginning extension record for path type 4 (as Fixnum). Value is in database units.

# File lib/gdsii/path.rb, line 128
def bgnextn_record(); @records.get(GRT_BGNEXTN); end
endextn() click to toggle source

Get the ending extension for path type 4 (as Fixnum). Value is in database units.

# File lib/gdsii/path.rb, line 146
def endextn(); @records.get_data(GRT_ENDEXTN); end
endextn=(val) click to toggle source

Set the ending extension for path type 4 (as Fixnum). Value is in database units.

# File lib/gdsii/path.rb, line 137
def endextn=(val)
  ensure_pathtype_4
  @records.set(GRT_ENDEXTN, val)
end
endextn_record() click to toggle source

Get the ending extension record for path type 4 (as Fixnum). Value is in database units.

# File lib/gdsii/path.rb, line 152
def endextn_record(); @records.get(GRT_ENDEXTN); end

Private Instance Methods

ensure_pathtype_4() click to toggle source

Ensures that pathtype == 4. This needs to be verified for a few of the methods only relevant for pathtype == 4 (see bgnextn and endextn).

# File lib/gdsii/path.rb, line 162
def ensure_pathtype_4()
  if pathtype != 4
    raise TypeError, "Attempt to access a method only relevant to pathtype == 4"
  end
end