Class: ZIMG::JPEG::DHT
Overview
Define Huffman Table
Instance Attribute Summary collapse
-
#id ⇒ Object
Returns the value of attribute id.
-
#tables ⇒ Object
Returns the value of attribute tables.
Attributes inherited from Chunk
Instance Method Summary collapse
-
#initialize(marker, io) ⇒ DHT
constructor
A new instance of DHT.
- #inspect(verbose = 0) ⇒ Object
Methods inherited from Chunk
Methods inherited from Chunk
Constructor Details
#initialize(marker, io) ⇒ DHT
Returns a new instance of DHT.
179 180 181 182 183 184 185 186 187 188 |
# File 'lib/zimg/jpeg/chunks.rb', line 179 def initialize(marker, io) super @tables = {} sio = StringIO.new(@data) until sio.eof? id, *lengths = sio.read(17).unpack("C*") values = sio.read(lengths.inject(:+)).unpack("C*") @tables[id] = [lengths, values] end end |
Instance Attribute Details
#id ⇒ Object
Returns the value of attribute id.
177 178 179 |
# File 'lib/zimg/jpeg/chunks.rb', line 177 def id @id end |
#tables ⇒ Object
Returns the value of attribute tables.
177 178 179 |
# File 'lib/zimg/jpeg/chunks.rb', line 177 def tables @tables end |
Instance Method Details
#inspect(verbose = 0) ⇒ Object
190 191 192 193 194 |
# File 'lib/zimg/jpeg/chunks.rb', line 190 def inspect(verbose = 0) r = super.chop + format("ids=%s >", tables.keys.inspect) r = r.chop + format("tables=%s >", tables.values.inspect) if verbose > 0 r end |