Class: BitStream::ReaderArray

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

Instance Method Summary collapse

Constructor Details

#initializeReaderArray

Returns a new instance of ReaderArray.



142
143
144
145
# File 'lib/bitstream.rb', line 142

def initialize
  @array = []
  @read  = []
end

Instance Method Details

#<<(reader) ⇒ Object



159
160
161
# File 'lib/bitstream.rb', line 159

def <<(reader)
  @array << reader
end

#[](pos) ⇒ Object



147
148
149
150
151
152
153
154
155
156
157
# File 'lib/bitstream.rb', line 147

def [](pos)
  unless @read[pos]
    @read[pos] = true
    reader = @array[pos]
    if reader.value.nil?
      reader.read
    end
    @array[pos] = reader.value
  end
  return @array[pos]
end