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)


582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
# File 'lib/nmatrix/io/mat5_reader.rb', line 582

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