Class: NMatrix::IO::Matlab::Mat5Reader::Header

Inherits:
Struct
  • Object
show all
Includes:
Packable
Defined in:
lib/nmatrix/io/mat5_reader.rb

Overview

Internal Classes.

Constant Summary collapse

BYTE_ORDER_LENGTH =
2
DESC_LENGTH =
116
DATA_OFFSET_LENGTH =
8
VERSION_LENGTH =
2
BYTE_ORDER_POS =
126

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#data_offsetObject

Returns the value of attribute data_offset

Returns:

  • (Object)

    the current value of data_offset



406
407
408
# File 'lib/nmatrix/io/mat5_reader.rb', line 406

def data_offset
  @data_offset
end

#descObject

Returns the value of attribute desc

Returns:

  • (Object)

    the current value of desc



406
407
408
# File 'lib/nmatrix/io/mat5_reader.rb', line 406

def desc
  @desc
end

#endianObject

Returns the value of attribute endian

Returns:

  • (Object)

    the current value of endian



406
407
408
# File 'lib/nmatrix/io/mat5_reader.rb', line 406

def endian
  @endian
end

#versionObject

Returns the value of attribute version

Returns:

  • (Object)

    the current value of version



406
407
408
# File 'lib/nmatrix/io/mat5_reader.rb', line 406

def version
  @version
end

Instance Method Details

#read_packed(packedio, options) ⇒ Object



424
425
426
427
428
429
430
431
432
433
434
435
436
# File 'lib/nmatrix/io/mat5_reader.rb', line 424

def read_packed(packedio, options)
  self.desc, self.data_offset, self.version, self.endian = packedio >>
    [String, {:bytes => DESC_LENGTH                 }] >>
    [String, {:bytes => DATA_OFFSET_LENGTH              }] >>
    [Integer, {:bytes => VERSION_LENGTH, :endian => options[:endian] }] >>
    [String, {:bytes => 2                      }]

  self.desc.strip!
  self.data_offset.strip!
  self.data_offset = nil if self.data_offset.empty?

  self.endian == 'IM' ? :little : :big
end

#write_packed(packedio, options) ⇒ Object

TODO: TEST WRITE.



417
418
419
420
421
422
# File 'lib/nmatrix/io/mat5_reader.rb', line 417

def write_packed(packedio, options)
  packedio << [desc,    {:bytes => DESC_LENGTH    }] <<
    [data_offset, {:bytes => DATA_OFFSET_LENGTH }] <<
    [version,   {:bytes => VERSION_LENGTH   }] <<
    [byte_order, {:bytes => BYTE_ORDER_LENGTH }]
end