Module: BitStream

Defined in:
lib/bitstream/utils.rb,
lib/bitstream.rb,
lib/types/string.rb,
lib/types/cstring.rb,
lib/types/integer.rb,
lib/types/character.rb,
lib/types/string-utils.rb

Overview

Author

Natsuki Kawai ([email protected])

Copyright

Copyright © 2012 Natsuki Kawai

License

2-clause BSDL or Ruby’s

Defined Under Namespace

Modules: ClassMethods, Utils Classes: ArrayProxy, BitStreamError, Char, Cstring, FieldReader, NestWrapper, Properties, Queue, ReaderArray, Signed, String, SubStreamPacket, Unsigned

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#bitstream_propertiesObject

end



565
566
567
# File 'lib/bitstream.rb', line 565

def bitstream_properties
  @bitstream_properties
end

Class Method Details

.included(obj) ⇒ Object



523
524
525
526
# File 'lib/bitstream.rb', line 523

def self.included(obj)
  obj.extend ClassMethods
  obj.initialize_for_class_methods(ClassMethods.types)
end

Instance Method Details

#initialize_properties(s, offset = 0) ⇒ Object



533
534
535
536
537
538
539
540
541
542
543
544
# File 'lib/bitstream.rb', line 533

def initialize_properties(s, offset = 0)
  props = Properties.new
  props.curr_offset = offset
  props.fields = {}
  props.raw_data = s
  props.initial_offset = offset
  props.eval_queue = Queue.new
  props.substreams = Hash.new do |hash, key|
    hash[key] = []
  end
  @bitstream_properties = props
end

#initialize_with_fieldsObject



528
529
530
531
# File 'lib/bitstream.rb', line 528

def initialize_with_fields
  # Nothing to do.
  # Override me if you want to do anything after all fields has been defined.
end

#lengthObject



546
547
548
549
550
551
# File 'lib/bitstream.rb', line 546

def length
  props = @bitstream_properties
  queue = props.eval_queue
  queue.peek_back.index unless queue.empty?
  props.curr_offset - props.initial_offset
end

#substreamsObject



553
554
555
# File 'lib/bitstream.rb', line 553

def substreams
  @bitstream_properties.substreams.values
end