Class: NMatrix::IO::Matlab::Mat5Reader::RawElement

Inherits:
Element
  • Object
show all
Defined in:
lib/nmatrix/io/mat5_reader.rb

Overview

Doesn't unpack the contents of the element, e.g., if we want to handle manually, or pass the raw string of bytes into NMatrix.

Instance Attribute Summary

Attributes inherited from Element

#data, #tag

Instance Method Summary collapse

Methods inherited from Element

#ignore_padding, #to_ruby, #write_packed

Instance Method Details

#read_packed(packedio, options) ⇒ Object

:nodoc:

Raises:

  • (ArgumentError)

560
561
562
563
564
565
566
567
568
569
570
571
572
573
# File 'lib/nmatrix/io/mat5_reader.rb', line 560

def read_packed(packedio, options)
  raise(ArgumentError, 'Missing mandatory option :endian.') unless options.has_key?(:endian)

  self.tag = packedio.read([Tag,   {:endian => options[:endian]           }])
  self.data = packedio.read([String, {:endian => options[:endian], :bytes => tag.bytes }])

  begin
    ignore_padding(packedio, (tag.bytes + tag.size) % 8) unless [:miMATRIX, :miCOMPRESSED].include?(tag.data_type)

  rescue EOFError
    STDERR.puts self.tag.inspect
    raise ElementDataIOError.new(tag, 'Ignored too much.')
  end
end