Class: NMatrix::IO::Matlab::Mat5Reader::Tag
- Includes:
- Packable
- Defined in:
- lib/nmatrix/io/mat5_reader.rb
Overview
:nodoc:
Constant Summary collapse
- DATA_TYPE_OPTS =
BYTES_OPTS = {:bytes => 4, :signed => false}
- LENGTH =
Instance Attribute Summary collapse
-
#bytes ⇒ Object
Returns the value of attribute bytes.
-
#data_type ⇒ Object
Returns the value of attribute data_type.
-
#raw_data_type ⇒ Object
Returns the value of attribute raw_data_type.
-
#small ⇒ Object
Returns the value of attribute small.
Instance Method Summary collapse
- #inspect ⇒ Object
- #read_packed(packedio, options) ⇒ Object
- #size ⇒ Object
- #small? ⇒ Boolean
-
#write_packed(packedio, options) ⇒ Object
TODO: TEST WRITE.
Instance Attribute Details
#bytes ⇒ Object
Returns the value of attribute bytes
439 440 441 |
# File 'lib/nmatrix/io/mat5_reader.rb', line 439 def bytes @bytes end |
#data_type ⇒ Object
Returns the value of attribute data_type
439 440 441 |
# File 'lib/nmatrix/io/mat5_reader.rb', line 439 def data_type @data_type end |
#raw_data_type ⇒ Object
Returns the value of attribute raw_data_type
439 440 441 |
# File 'lib/nmatrix/io/mat5_reader.rb', line 439 def raw_data_type @raw_data_type end |
#small ⇒ Object
Returns the value of attribute small
439 440 441 |
# File 'lib/nmatrix/io/mat5_reader.rb', line 439 def small @small end |
Instance Method Details
#inspect ⇒ Object
479 480 481 |
# File 'lib/nmatrix/io/mat5_reader.rb', line 479 def inspect "#<#{self.class.to_s} data_type=#{data_type}[#{raw_data_type}][#{raw_data_type.to_s(2)}] bytes=#{bytes} size=#{size}#{small? ? ' small' : ''}>" end |
#read_packed(packedio, options) ⇒ Object
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 |
# File 'lib/nmatrix/io/mat5_reader.rb', line 458 def read_packed packedio, self.raw_data_type = packedio.read([Integer, DATA_TYPE_OPTS.merge()]) # Borrowed from a SciPy patch upper = self.raw_data_type >> 16 lower = self.raw_data_type & 0xFFFF if upper > 0 # Small data element format raise IOError, 'Small data element format indicated, but length is more than 4 bytes!' if upper > 4 self.bytes = upper self.raw_data_type = lower else self.bytes = packedio.read([Integer, BYTES_OPTS.merge()]) end self.data_type = MatReader::MDTYPES[self.raw_data_type] end |
#size ⇒ Object
454 455 456 |
# File 'lib/nmatrix/io/mat5_reader.rb', line 454 def size small? ? 4 : 8 end |
#small? ⇒ Boolean
450 451 452 |
# File 'lib/nmatrix/io/mat5_reader.rb', line 450 def small? self.bytes > 0 and self.bytes <= 4 end |
#write_packed(packedio, options) ⇒ Object
TODO: TEST WRITE.
446 447 448 |
# File 'lib/nmatrix/io/mat5_reader.rb', line 446 def write_packed packedio, packedio << [data_type, DATA_TYPE_OPTS] << [bytes, BYTES_OPTS] end |