Class: Gdsii::Path

Inherits:
Element
  • Object
show all
Includes:
Access::Datatype, Access::ELFlags, Access::Layer, Access::PathType, Access::Plex, Access::Width, Access::XY
Defined in:
lib/gdsii/path.rb

Overview

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

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Access::Plex

#plex, #plex=, #plex_record

Methods included from Access::ELFlags

#elflags, #elflags=, #elflags_record

Methods included from Access::Width

#width, #width=, #width_record

Methods included from Access::PathType

#pathtype, #pathtype=, #pathtype_record

Methods included from Access::XY

#xy, #xy=, #xy_record

Methods included from Access::Datatype

#datatype, #datatype=, #datatype_record

Methods included from Access::Layer

#layer, #layer=, #layer_record

Constructor Details

#initialize(layer = nil, datatype = nil, pathtype = nil, width = nil, xy = nil) {|_self| ... } ⇒ Path

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])

Yields:

  • (_self)

Yield Parameters:

  • _self (Gdsii::Path)

    the object that the method was called on



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# 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

Class Method Details

.new0(layer = nil, datatype = nil, width = nil, xy = nil) ⇒ Object

Creates a path of type 0



74
75
76
# 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) ⇒ Object

Creates a path of type 1



81
82
83
# 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) ⇒ Object

Creates a path of type 2



88
89
90
# 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) ⇒ Object

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])


97
98
99
100
101
102
103
104
# 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

Instance Method Details

#bgnextnObject

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



122
# File 'lib/gdsii/path.rb', line 122

def bgnextn(); @records.get_data(GRT_BGNEXTN); end

#bgnextn=(val) ⇒ Object

Set the beginning extension for path type 4 (as Fixnum). Value is in database units. – TODO: more explanation of database units; also example ++



113
114
115
116
# File 'lib/gdsii/path.rb', line 113

def bgnextn=(val)
  ensure_pathtype_4
  @records.set(GRT_BGNEXTN, val)
end

#bgnextn_recordObject

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



128
# File 'lib/gdsii/path.rb', line 128

def bgnextn_record(); @records.get(GRT_BGNEXTN); end

#endextnObject

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



146
# File 'lib/gdsii/path.rb', line 146

def endextn(); @records.get_data(GRT_ENDEXTN); end

#endextn=(val) ⇒ Object

Set the ending extension for path type 4 (as Fixnum). Value is in database units. – TODO: more explanation of database units; also example ++



137
138
139
140
# File 'lib/gdsii/path.rb', line 137

def endextn=(val)
  ensure_pathtype_4
  @records.set(GRT_ENDEXTN, val)
end

#endextn_recordObject

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



152
# File 'lib/gdsii/path.rb', line 152

def endextn_record(); @records.get(GRT_ENDEXTN); end