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

#==, #=~, #abs_offset, arg_processor, auto_call_delayed_io, bindata_name, #clear, #debug_name, #eval_parameter, #get_parameter, #has_parameter?, #initialize_instance, #initialize_with_warning, #inspect, #lazy_evaluator, #new, #num_bytes, #pretty_print, #read, read, register_subclasses, #rel_offset, #safe_respond_to?, #to_binary_s, #to_hex, #to_s, unregister_self, #write

Methods included from AcceptedParametersPlugin

#accepted_parameters, #default_parameters, #mandatory_parameters, #mutually_exclusive_parameters, #optional_parameters

Methods included from RegisterNamePlugin

included, #initialize_shared_instance

Methods included from Framework

#bit_aligned?, #debug_name_of, #offset_of

Instance Method Details

#assign(val) ⇒ Object



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

def assign(val); end

#clear?Boolean

Returns:

  • (Boolean)


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

def clear?; true; end

#do_num_bytesObject



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

def do_num_bytes; 0; end

#do_read(io) ⇒ Object



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

def do_read(io)
  io.readbytes(0)
end

#do_write(io) ⇒ Object



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

def do_write(io)
  io.writebytes("")
end

#snapshotObject



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

def snapshot; nil; end