Class: Gifenc::Extension

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

Overview

TODO:

Add support for the Plain Text Extension and the Comment Extension.

Generic container for GIF extensions. Extensions were added in the second and final specification of the GIF format in 1989, and implement additional and extensible functionality to GIF files.

Direct Known Subclasses

Application, GraphicControl

Defined Under Namespace

Classes: Application, GraphicControl, Netscape

Constant Summary collapse

EXTENSION_INTRODUCER =

1-byte field indicating the beginning of an extension block.

'!'.freeze

Instance Method Summary collapse

Constructor Details

#initialize(label) ⇒ Extension

Create a new generic extension block.

Parameters:

  • label (Integer)

    Label of the extension, uniquely identifies the type of extension.



15
16
17
# File 'lib/extensions.rb', line 15

def initialize(label)
  @label = label
end

Instance Method Details

#encode(stream) ⇒ Object

Encode the extension data to GIF format and write it to a stream.

Parameters:

  • stream (IO)

    Stream to write the data to.



21
22
23
24
25
# File 'lib/extensions.rb', line 21

def encode(stream)
  stream << EXTENSION_INTRODUCER
  stream << @label # Extension label
  stream << body   # Extension content
end