Class: BinData::ResumeByteAlignment

Inherits:
Base
  • Object
show all
Defined in:
lib/bindata/alignment.rb

Overview

Resets the stream alignment to the next byte. This is only useful when using bit-based primitives.

class MyRec < BinData::Record
  bit4 :a
  resume_byte_alignment
  bit4 :b
end

MyRec.read("\x12\x34") #=> {"a" => 1, "b" => 3}

Instance Attribute Summary

Attributes inherited from Base

#parent

Instance Method Summary collapse

Methods inherited from Base

#==, #=~, arg_extractor, bindata_name, #debug_name, #debug_name_of, #eval_parameter, #get_parameter, #has_parameter?, #initialize_instance, #initialize_with_warning, #inspect, #lazy_evaluator, #new, #num_bytes, #offset, #offset_of, #pretty_print, #read, read, register_subclasses, #rel_offset, #safe_respond_to?, #to_binary_s, #to_s, unregister_self, #write

Methods included from CheckOrAdjustOffsetMixin

#do_read_with_adjust_offset, #do_read_with_check_offset, included

Methods included from AcceptedParametersMixin

included

Instance Method Details

#assign(val) ⇒ Object



18
# File 'lib/bindata/alignment.rb', line 18

def assign(val); end

#clearObject



16
# File 'lib/bindata/alignment.rb', line 16

def clear; end

#clear?Boolean

Returns:

  • (Boolean)


17
# File 'lib/bindata/alignment.rb', line 17

def clear?; true; end

#do_num_bytesObject



20
# File 'lib/bindata/alignment.rb', line 20

def do_num_bytes; 0; end

#do_read(io) ⇒ Object



22
23
24
# File 'lib/bindata/alignment.rb', line 22

def do_read(io)
  io.reset_read_bits
end

#do_write(io) ⇒ Object



26
27
28
# File 'lib/bindata/alignment.rb', line 26

def do_write(io)
  io.flushbits
end

#snapshotObject



19
# File 'lib/bindata/alignment.rb', line 19

def snapshot; nil; end