Class: Pocolog::BlockStream::DataBlockHeader

Inherits:
Object
  • Object
show all
Defined in:
lib/pocolog/block_stream.rb

Overview

Information about a data block

Direct Known Subclasses

Logfiles::DataHeader

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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_sizeObject (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_timeObject (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_timeObject (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

Returns:

  • (Boolean)


299
300
301
# File 'lib/pocolog/block_stream.rb', line 299

def compressed?
    @compressed
end

#lgObject



329
330
331
# File 'lib/pocolog/block_stream.rb', line 329

def lg
    StreamIndex.time_from_internal(lg_time, 0)
end

#rtObject



325
326
327
# File 'lib/pocolog/block_stream.rb', line 325

def rt
    StreamIndex.time_from_internal(rt_time, 0)
end