Class: Gdsii::ARef
- Inherits:
-
Element
- Object
- Element
- Gdsii::ARef
- Includes:
- Gdsii::Access::ELFlags, Gdsii::Access::Plex, Gdsii::Access::Sname, Gdsii::Access::StransGroup
- Defined in:
- lib/gdsii/aref.rb
Overview
Represents a GDSII structure array reference (ARef) element. Most methods are from Element or from the various included Access module methods.
Instance Method Summary collapse
-
#colrow ⇒ Object
Get the colrow array of numbers (returns 2-element Array of Fixnum) where the first number is columns and the second is rows [col, row].
-
#colrow=(val) ⇒ Object
Set the colrow number (see #colrow for format details).
-
#colrow_record ⇒ Object
Get the colrow record (returns Record).
-
#column_space ⇒ Object
Returns the placement XY coordinate for this ARef.
-
#column_space=(val) ⇒ Object
Defines the column spacing (in units) for this ARef.
-
#columns ⇒ Object
Get the columns number in the COLROW record (returns Fixnum).
-
#columns=(val) ⇒ Object
Set the columns number in the COLROW record (Fixnum).
-
#initialize(sname = nil, ref_xy = nil, colrow = nil, colrow_spc = nil) {|_self| ... } ⇒ ARef
constructor
Create a new structure array reference (ARef) to be used within a Structure object.
-
#ref_xy ⇒ Object
Returns the placement XY coordinate for this ARef.
-
#ref_xy=(val) ⇒ Object
Defines the placement XY coordinate for this ARef.
-
#row_space ⇒ Object
Returns the placement XY coordinate for this ARef.
-
#row_space=(val) ⇒ Object
Defines the row spacing (in units) for this ARef.
-
#rows ⇒ Object
Get the rows number in the COLROW record (returns Fixnum).
-
#rows=(val) ⇒ Object
Set the rows number in the COLROW record.
-
#xy ⇒ Object
Gets an xy point record (returns an Array).
-
#xy_record ⇒ Object
Gets the ARef record for XY.
Methods included from Gdsii::Access::Sname
#sname, #sname=, #sname_record
Methods included from Gdsii::Access::StransGroup
Methods included from Gdsii::Access::Plex
Methods included from Gdsii::Access::ELFlags
#elflags, #elflags=, #elflags_record
Constructor Details
#initialize(sname = nil, ref_xy = nil, colrow = nil, colrow_spc = nil) {|_self| ... } ⇒ ARef
Create a new structure array reference (ARef) to be used within a Structure object. The structure name is a String or anything that has a #to_s method. The ref_xy is a single set of x/y coordinates that the placement of the ARef (note this is NOT the same as the XY record for ARef - see #xy_record for more details). The colrow is an array of a number of columns and rows respectively. The colrow_spc is an array of spacing values for columns and rows respectively.
# Create an ARef at coordinates (0,0) with 2 columns and 8 rows. The
# spacing between columns is 200 units and between rows is 300 units.
aref = ARef.new('array', [0,0], [2,8], [200, 300])
Note, the #ref_xy, #column_space, and #row_space are required. See #xy_record for details.
53 54 55 56 57 58 59 60 61 62 |
# File 'lib/gdsii/aref.rb', line 53 def initialize(sname=nil, ref_xy=nil, colrow=nil, colrow_spc=nil) super() @records[GRT_AREF] = Record.new(GRT_AREF) self.sname = sname unless sname.nil? self.colrow = colrow unless colrow.nil? self.ref_xy = ref_xy unless ref_xy.nil? self.column_space = colrow_spc[0] if colrow_spc.class == Array self.row_space = colrow_spc[1] if colrow_spc.class == Array yield self if block_given? end |
Instance Method Details
#colrow ⇒ Object
Get the colrow array of numbers (returns 2-element Array of Fixnum) where the first number is columns and the second is rows [col, row]. Alternatively, the #rows and #columns method may also be used.
aref.colrow #=> [2, 8]
76 |
# File 'lib/gdsii/aref.rb', line 76 def colrow() @records.get_data(GRT_COLROW); end |
#colrow=(val) ⇒ Object
Set the colrow number (see #colrow for format details). Alternatively, the #rows= and #columns= methods may be used.
aref.colrow = [2, 8]
84 |
# File 'lib/gdsii/aref.rb', line 84 def colrow=(val) @records.set(GRT_COLROW, val); end |
#colrow_record ⇒ Object
Get the colrow record (returns Record)
67 |
# File 'lib/gdsii/aref.rb', line 67 def colrow_record() @records.get(GRT_COLROW); end |
#column_space ⇒ Object
Returns the placement XY coordinate for this ARef. See #xy_record for details on how the XY record is used in ARef.
aref.column_space #=> 200
171 |
# File 'lib/gdsii/aref.rb', line 171 def column_space(); @column_space; end |
#column_space=(val) ⇒ Object
Defines the column spacing (in units) for this ARef. Internally this value is stored in the XY record. See #xy_record for details on how the XY record is used in ARef.
aref.column_space = 200
160 161 162 163 |
# File 'lib/gdsii/aref.rb', line 160 def column_space=(val) @column_space = val update_xy end |
#columns ⇒ Object
Get the columns number in the COLROW record (returns Fixnum)
aref.columns #=> 2
104 105 106 |
# File 'lib/gdsii/aref.rb', line 104 def columns() (cr=@records.get(GRT_COLROW)) ? cr[0] : nil end |
#columns=(val) ⇒ Object
Set the columns number in the COLROW record (Fixnum)
aref.columns = 2
91 92 93 94 95 96 97 |
# File 'lib/gdsii/aref.rb', line 91 def columns=(val) if (cr=colrow) @records.set(GRT_COLROW, [val, cr[1]]) else @records.set(GRT_COLROW, [val, nil]) end end |
#ref_xy ⇒ Object
Returns the placement XY coordinate for this ARef. See #xy_record for details on how the XY record is used in ARef.
aref.ref_xy #=> [10, 20]
151 |
# File 'lib/gdsii/aref.rb', line 151 def ref_xy(); @ref_xy; end |
#ref_xy=(val) ⇒ Object
Defines the placement XY coordinate for this ARef. See #xy_record for details on how the XY record is used in ARef.
aref.ref_xy = [10, 20]
136 137 138 139 140 141 142 143 |
# File 'lib/gdsii/aref.rb', line 136 def ref_xy=(val) if val.class == Array and val.length == 2 @ref_xy = val update_xy else raise TypeError, "Expected Array of length 2" end end |
#row_space ⇒ Object
Returns the placement XY coordinate for this ARef. See #xy_record for details on how the XY record is used in ARef.
aref.row_space #=> 300
191 |
# File 'lib/gdsii/aref.rb', line 191 def row_space(); @row_space; end |
#row_space=(val) ⇒ Object
Defines the row spacing (in units) for this ARef. Internally this value is stored in the XY record. See #xy_record for details on how the XY record is used in ARef.
aref.row_space = 300
180 181 182 183 |
# File 'lib/gdsii/aref.rb', line 180 def row_space=(val) @row_space = val update_xy end |
#rows ⇒ Object
Get the rows number in the COLROW record (returns Fixnum)
aref.rows #=> 8
126 127 128 |
# File 'lib/gdsii/aref.rb', line 126 def rows() (cr=@records.get(GRT_COLROW)) ? cr[1] : nil end |
#rows=(val) ⇒ Object
Set the rows number in the COLROW record
aref.rows = 8
113 114 115 116 117 118 119 |
# File 'lib/gdsii/aref.rb', line 113 def rows=(val) if (cr=colrow) @records.set(GRT_COLROW, [cr[0], val]) else @records.set(GRT_COLROW, [nil, val]) end end |
#xy ⇒ Object
Gets an xy point record (returns an Array). Note, it is probably easier to use #ref_xy, #column_space, or #row_space instead; see #xy_record for details on how the XY record is used for ARef.
215 |
# File 'lib/gdsii/aref.rb', line 215 def xy() @records.get_data(GRT_XY); end |
#xy_record ⇒ Object
Gets the ARef record for XY.
Important note on the XY record (i.e. #xy, #xy_record): the GDSII specification calls for exactly 3 XY records for ARef. Because of this specification, there is no #xy= method available for the ARef class. Instead, the XY record is created dynamically when all three of these components are set. Otherwise, the XY record will not exist.
The XY record data specification is as follows:
-
1: ARef reference point (#ref_xy)
-
2: column_space*columns+reference_x (#ref_xy, #columns, and #column_space)
-
3: row_space*rows+reference_y (#ref_xy, #rows, and #row_space)
208 |
# File 'lib/gdsii/aref.rb', line 208 def xy_record() @records.get(GRT_XY); end |