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



422
423
424
# File 'lib/nmatrix/io/mat5_reader.rb', line 422

def data_offset
  @data_offset
end

#descObject

Returns the value of attribute desc

Returns:

  • (Object)

    the current value of desc



422
423
424
# File 'lib/nmatrix/io/mat5_reader.rb', line 422

def desc
  @desc
end

#endianObject

Returns the value of attribute endian

Returns:

  • (Object)

    the current value of endian



422
423
424
# File 'lib/nmatrix/io/mat5_reader.rb', line 422

def endian
  @endian
end

#versionObject

Returns the value of attribute version

Returns:

  • (Object)

    the current value of version



422
423
424
# File 'lib/nmatrix/io/mat5_reader.rb', line 422

def version
  @version
end

Instance Method Details

#read_packed(packedio, options) ⇒ Object



440
441
442
443
444
445
446
447
448
449
450
451
452
# File 'lib/nmatrix/io/mat5_reader.rb', line 440

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.



433
434
435
436
437
438
# File 'lib/nmatrix/io/mat5_reader.rb', line 433

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