Class: ChunkyPNG::Chunk::End

Inherits:
Base
  • Object
show all
Defined in:
lib/chunky_png/chunk.rb

Overview

The End (IEND) chunk indicates the last chunk of a PNG stream. It does not contain any data.

Instance Attribute Summary

Attributes inherited from Base

#type

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods inherited from Base

#write, #write_with_crc

Constructor Details

- (End) initialize

Returns a new instance of End



151
152
153
# File 'lib/chunky_png/chunk.rb', line 151

def initialize
  super('IEND')
end

Class Method Details

+ (ChunkyPNG::Chunk::End) read(type, content)

Reads the END chunk. It will check if the content is empty.

Parameters:

  • type (String)

    The four character chunk type indicator (= “IEND”).

  • content (String)

    The content read from the chunk. Should be empty.

Returns:

Raises:

  • (RuntimeError)

    Raises an exception if the content was not empty.



162
163
164
165
# File 'lib/chunky_png/chunk.rb', line 162

def self.read(type, content)
  raise ExpectationFailed, 'The IEND chunk should be empty!' if content.bytesize > 0
  self.new
end

Instance Method Details

- ("") content

Returns an empty string, because this chunk should always be empty.

Returns:

  • ("")

    An empty string.



169
170
171
# File 'lib/chunky_png/chunk.rb', line 169

def content
  ChunkyPNG::Datastream.empty_bytearray
end