Class: ChunkyPNG::Chunk::Generic

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

Overview

The Generic chunk type will read the content from the chunk as it, and will write it back as it was read.

Direct Known Subclasses

ImageData, Palette, Transparency

Instance Attribute Summary collapse

Attributes inherited from Base

#type

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#write, #write_with_crc

Constructor Details

#initialize(type, content = "") ⇒ Generic

Returns a new instance of Generic.



100
101
102
# File 'lib/chunky_png/chunk.rb', line 100

def initialize(type, content = "")
  super(type, content: content)
end

Instance Attribute Details

#contentObject

The attribute to store the content from the chunk, which gets written by the write method.



98
99
100
# File 'lib/chunky_png/chunk.rb', line 98

def content
  @content
end

Class Method Details

.read(type, content) ⇒ ChunkyPNG::Chunk::Generic

Creates an instance, given the chunk’s type and content.

Parameters:

  • type (String)

    The four character chunk type indicator.

  • content (String)

    The content read from the chunk.

Returns:



108
109
110
# File 'lib/chunky_png/chunk.rb', line 108

def self.read(type, content)
  new(type, content)
end