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
455 456 457 |
# File 'lib/nmatrix/io/mat5_reader.rb', line 455 def bytes @bytes end |
#data_type ⇒ Object
Returns the value of attribute data_type
455 456 457 |
# File 'lib/nmatrix/io/mat5_reader.rb', line 455 def data_type @data_type end |
#raw_data_type ⇒ Object
Returns the value of attribute raw_data_type
455 456 457 |
# File 'lib/nmatrix/io/mat5_reader.rb', line 455 def raw_data_type @raw_data_type end |
#small ⇒ Object
Returns the value of attribute small
455 456 457 |
# File 'lib/nmatrix/io/mat5_reader.rb', line 455 def small @small end |
Instance Method Details
#inspect ⇒ Object
496 497 498 |
# File 'lib/nmatrix/io/mat5_reader.rb', line 496 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
474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 |
# File 'lib/nmatrix/io/mat5_reader.rb', line 474 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
470 471 472 |
# File 'lib/nmatrix/io/mat5_reader.rb', line 470 def size small? ? 4 : 8 end |
#small? ⇒ Boolean
466 467 468 |
# File 'lib/nmatrix/io/mat5_reader.rb', line 466 def small? self.bytes > 0 and self.bytes <= 4 end |
#write_packed(packedio, options) ⇒ Object
TODO: TEST WRITE.
462 463 464 |
# File 'lib/nmatrix/io/mat5_reader.rb', line 462 def write_packed packedio, packedio << [data_type, DATA_TYPE_OPTS] << [bytes, BYTES_OPTS] end |