class Gdsii::RecData::Int4
Class for INT4 data type
Attributes
value[R]
Value is an array of integers.
Public Class Methods
new(value)
click to toggle source
Construct an Gdsii::RecData::Int4 data object. The value is an array of integers (Fixnum).
Calls superclass method
Gdsii::RecData::Data.new
# File lib/gdsii/record/datatypes/int4.rb, line 18 def initialize(value) super(GDT_INT4, value) end
read(file, byte_count)
click to toggle source
Reads an INT4 record from the given file and for the length of bytes given and returns a new Gdsii::RecData::Int4 object.
# File lib/gdsii/record/datatypes/int4.rb, line 36 def Int4.read(file, byte_count) data = [] while (byte_count > 0) raw = file.read(4) raw.reverse! if (ByteOrder::little_endian?) data.push raw.unpack('i')[0] byte_count -= 4 end Int4.new(data) end
Public Instance Methods
byte_size()
click to toggle source
Returns the size of the record data in bytes. Each array element consumes 4 bytes (hence INT4).
# File lib/gdsii/record/datatypes/int4.rb, line 30 def byte_size() @value.length * 4 end
to_s()
click to toggle source
Converts the array of integer values to a string (values are joined by spaces).
# File lib/gdsii/record/datatypes/int4.rb, line 58 def to_s() value.map {|v| v.to_s}.join(' ') end
value=(value)
click to toggle source
Set the value for this object; verify that the value items are of type Fixnum (or at least can be coerced using “to_i”).
# File lib/gdsii/record/datatypes/int4.rb, line 24 def value=(value) @value = Data.coerce_value(value, Fixnum, :to_i) end
write(file)
click to toggle source
Writes the integer values in this Gdsii::RecData::Int2 object to the given file as a GDSII INT4 record.
# File lib/gdsii/record/datatypes/int4.rb, line 49 def write(file) value.each do |item| # always write int4 in network order (as per GDSII spec) file.write [item].pack('N') end end