class Gdsii::RecInfo

Class to store information about each record type. The Gdsii::RECORD_INFO constant is an array with an index of the record type number and the value being instances of this class. For example:

Gdsii::RECORD_INFO[Gdsii::GRT_HEADER].name    #=> 'HEADER'
Gdsii::RECORD_INFO[Gdsii::GRT_XY].min_len     #=> 4

See the Gdsii module for a complete listing of record type constants (Gdsii::GRT_*).

Attributes

data_type[R]

Data type is an integer of the constant Gdsii::GDT_* for this record. This represents the data type expected for this record.

max_len[R]

Maximum length (in bytes) to store this record

min_len[R]

Minimum length (in bytes) to store this record

name[R]

Name of this record (should be the same as the Gdsii::GRT_* name but without the “Gdsii::GRT_”.

size[R]

Size indicates how many bytes are necessary to store each element of this record. For example, the size of a Gdsii::GRT_XY record is 8 with a record size of 4 bytes for each record (since it's a Gdsii::GDT_INT4). This means that the minimum number of items needed (#min_items) is 2.

type[R]

Record type is an integer of the constant Gdsii::GRT_* for this record type.

valid[R]

Boolean as to whether or not this record is a valid GDS record (some records are not valid to the GDS specification)

Public Class Methods

new(name, data_type, valid, size, min_len, max_len) click to toggle source

Object constructor. Intended to be used internally only to add elements to the Gdsii::RECORD_INFO array.

# File lib/gdsii/record/consts.rb, line 46
def initialize(name, data_type, valid, size, min_len, max_len)
  @name = name
  @data_type = data_type
  @valid = valid
  @size = size
  @min_len = min_len
  @max_len = max_len
end

Public Instance Methods

max_items() click to toggle source

Returns the maximum number of items necessary for this record type.

# File lib/gdsii/record/consts.rb, line 66
def max_items
  case @data_type
  when GDT_NO_DATA  then 0
  when GDT_ASCII    then (@size == 0) ? 1 : @max_len/@size
  else 
    @max_len/@size
  end
end
min_items() click to toggle source

Returns the minimum number of items necessary for this record type.

# File lib/gdsii/record/consts.rb, line 56
def min_items
  case @data_type
  when GDT_NO_DATA  then 0
  when GDT_ASCII    then (@size == 0) ? 1 : @min_len/@size
  else 
    @min_len/@size
  end
end
single_data_value?() click to toggle source

Returns true if this object has only a single datum; false if it can have multiple data.

# File lib/gdsii/record/consts.rb, line 77
def single_data_value?
  if @data_type == GDT_ASCII
    @size == 0
  else
    @size == @min_len and @size == @max_len
  end
end
to_s() click to toggle source

Converts this record to a string (returns the record's name)

# File lib/gdsii/record/consts.rb, line 86
def to_s(); @name; end