Class: ChunkyPNG::Chunk::CompressedText
- Defined in:
- lib/chunky_png/chunk.rb
Overview
The CompressedText (zTXt) chunk contains keyword/value metadata about the PNG stream. In this chunk, the value is compressed using Deflate compression.
Instance Attribute Summary collapse
-
#keyword ⇒ Object
Returns the value of attribute keyword.
-
#value ⇒ Object
Returns the value of attribute value.
Attributes inherited from Base
Class Method Summary collapse
Instance Method Summary collapse
-
#content ⇒ Object
Creates the content to write to the stream, by concatenating the keyword with the deflated value, joined by a null character.
-
#initialize(keyword, value) ⇒ CompressedText
constructor
A new instance of CompressedText.
Methods inherited from Base
Constructor Details
#initialize(keyword, value) ⇒ CompressedText
Returns a new instance of CompressedText.
334 335 336 337 |
# File 'lib/chunky_png/chunk.rb', line 334 def initialize(keyword, value) super("zTXt") @keyword, @value = keyword, value end |
Instance Attribute Details
#keyword ⇒ Object
Returns the value of attribute keyword.
332 333 334 |
# File 'lib/chunky_png/chunk.rb', line 332 def keyword @keyword end |
#value ⇒ Object
Returns the value of attribute value.
332 333 334 |
# File 'lib/chunky_png/chunk.rb', line 332 def value @value end |
Class Method Details
.read(type, content) ⇒ Object
339 340 341 342 343 |
# File 'lib/chunky_png/chunk.rb', line 339 def self.read(type, content) keyword, compression, value = content.unpack("Z*Ca*") raise ChunkyPNG::NotSupported, "Compression method #{compression.inspect} not supported!" unless compression == ChunkyPNG::COMPRESSION_DEFAULT new(keyword, Zlib::Inflate.inflate(value)) end |
Instance Method Details
#content ⇒ Object
Creates the content to write to the stream, by concatenating the keyword with the deflated value, joined by a null character.
349 350 351 352 353 354 355 |
# File 'lib/chunky_png/chunk.rb', line 349 def content [ keyword, ChunkyPNG::COMPRESSION_DEFAULT, Zlib::Deflate.deflate(value), ].pack("Z*Ca*") end |