class BitStream::FieldReader

Attributes

offset[RW]

Public Class Methods

new(type, instance) click to toggle source
# File lib/bitstream.rb, line 167
def initialize(type, instance)
  @type = type
  @instance = instance
end

Public Instance Methods

index() click to toggle source
# File lib/bitstream.rb, line 205
def index
  queue = props.eval_queue
  
  while @offset.nil?
    field = queue.deq
    field.offset = props.curr_offset
    length = field.length
    props.curr_offset += length
  end
end
length() click to toggle source
# File lib/bitstream.rb, line 189
def length
  length = @type.length
  # @length must not be nil if @has_read.
  if length.nil?
    if @info.nil?
      if @offset.nil?
        index
      end
      @info = @type.read(props.raw_data, @offset)
    end
    return @info[:length]
  else
    return length
  end
end
read() click to toggle source
# File lib/bitstream.rb, line 177
def read
  if @info.nil?
    if @offset.nil?
      index
    end
    @info = @type.read(props.raw_data, @offset)
  end
  return @info[:value]
end
Also aliased as: value
value()
Alias for: read

Private Instance Methods

props() click to toggle source
# File lib/bitstream.rb, line 172
def props
  @instance.bitstream_properties
end