Class: BitStream::SubStreamPacket

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(length) ⇒ SubStreamPacket

Returns a new instance of SubStreamPacket.



122
123
124
125
126
127
# File 'lib/bitstream.rb', line 122

def initialize(length)
  if length % 8 != 0
    raise NotImplementedError, "non-aligned substream has not been supported."
  end
  @length = length
end

Instance Attribute Details

#lengthObject (readonly)

Returns the value of attribute length.



129
130
131
# File 'lib/bitstream.rb', line 129

def length
  @length
end

Class Method Details

.instance(length) ⇒ Object



118
119
120
# File 'lib/bitstream.rb', line 118

def self.instance(length)
  new length
end

Instance Method Details

#read(s, offset) ⇒ Object



131
132
133
134
135
136
# File 'lib/bitstream.rb', line 131

def read(s, offset)
  if offset % 8 != 0
    raise NotImplementedError, "non-aligned substream has not been supported."
  end
  return [LazyString.new(s, offset / 8, @length / 8), @length]
end