Class: Pocolog::BlockStream::DataBlockHeader
- Inherits:
-
Object
- Object
- Pocolog::BlockStream::DataBlockHeader
- Defined in:
- lib/pocolog/block_stream.rb
Overview
Information about a data block
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data_size ⇒ Object
readonly
Returns the value of attribute data_size.
-
#lg_time ⇒ Object
readonly
Returns the value of attribute lg_time.
-
#rt_time ⇒ Object
readonly
Returns the value of attribute rt_time.
Class Method Summary collapse
Instance Method Summary collapse
- #compressed? ⇒ Boolean
-
#initialize(rt_time, lg_time, data_size, compressed) ⇒ DataBlockHeader
constructor
A new instance of DataBlockHeader.
- #lg ⇒ Object
- #rt ⇒ Object
Constructor Details
#initialize(rt_time, lg_time, data_size, compressed) ⇒ DataBlockHeader
Returns a new instance of DataBlockHeader
318 319 320 321 322 323 |
# File 'lib/pocolog/block_stream.rb', line 318 def initialize(rt_time, lg_time, data_size, compressed) @rt_time = rt_time @lg_time = lg_time @data_size = data_size @compressed = compressed end |
Instance Attribute Details
#data_size ⇒ Object (readonly)
Returns the value of attribute data_size
297 298 299 |
# File 'lib/pocolog/block_stream.rb', line 297 def data_size @data_size end |
#lg_time ⇒ Object (readonly)
Returns the value of attribute lg_time
296 297 298 |
# File 'lib/pocolog/block_stream.rb', line 296 def lg_time @lg_time end |
#rt_time ⇒ Object (readonly)
Returns the value of attribute rt_time
295 296 297 |
# File 'lib/pocolog/block_stream.rb', line 295 def rt_time @rt_time end |
Class Method Details
.parse(raw_data) ⇒ Object
303 304 305 306 307 308 309 310 311 312 313 314 315 316 |
# File 'lib/pocolog/block_stream.rb', line 303 def self.parse(raw_data) if raw_data.size < Format::Current::DATA_BLOCK_HEADER_SIZE raise NotEnoughData, "expected #{Format::Current::DATA_BLOCK_HEADER_SIZE} bytes "\ "for a data block header, but got only #{raw_data.size}" end rt_sec, rt_usec, lg_sec, lg_usec, data_size, compressed = raw_data.unpack('VVVVVC') new(rt_sec * 1_000_000 + rt_usec, lg_sec * 1_000_000 + lg_usec, data_size, compressed != 0) end |
Instance Method Details
#compressed? ⇒ Boolean
299 300 301 |
# File 'lib/pocolog/block_stream.rb', line 299 def compressed? @compressed end |
#lg ⇒ Object
329 330 331 |
# File 'lib/pocolog/block_stream.rb', line 329 def lg StreamIndex.time_from_internal(lg_time, 0) end |
#rt ⇒ Object
325 326 327 |
# File 'lib/pocolog/block_stream.rb', line 325 def rt StreamIndex.time_from_internal(rt_time, 0) end |