Class: Gifenc::Extension::Netscape
- Inherits:
-
Application
- Object
- Gifenc::Extension
- Application
- Gifenc::Extension::Netscape
- Defined in:
- lib/extensions.rb
Overview
This is the only Application Extension block that is widely supported, so much so that it became a defacto standard. It controls whether the GIF should loop or not, and if so, how many times. It need only appear once in the GIF file, and for maximum compatibility, it should be the very first extension block in the GIF file (i.e., it should appear right after the Global Color Table). Structure:
- Sub-block ID (1 byte): Identifies the sub-block (always 1).
- Loop count (2 bytes): Number of iterations (0-65535) the GIF should be looped. A count of 0 means loop indefinitely.
Constant Summary
Constants inherited from Application
Constants inherited from Gifenc::Extension
Instance Attribute Summary collapse
-
#loops ⇒ Integer
The amount of times to loop the GIF.
Attributes inherited from Application
Instance Method Summary collapse
-
#data ⇒ String
Data of the actual extension as a 3-byte binary string.
-
#dup ⇒ Netscape
Create a duplicate copy of this Netscape extension.
-
#initialize(loops = 0) ⇒ Netscape
constructor
Create a new Netscape Extension block.
Methods inherited from Application
Methods inherited from Gifenc::Extension
Constructor Details
#initialize(loops = 0) ⇒ Netscape
Create a new Netscape Extension block.
255 256 257 258 |
# File 'lib/extensions.rb', line 255 def initialize(loops = 0) super('NETSCAPE', '2.0') @loops = loops.clamp(0, 2 ** 16 - 1) end |
Instance Attribute Details
#loops ⇒ Integer
The amount of times to loop the GIF. Must be between 0 and 65535, where 0 indicates to loop indefinitely.
250 251 252 |
# File 'lib/extensions.rb', line 250 def loops @loops end |
Instance Method Details
#data ⇒ String
Data of the actual extension as a 3-byte binary string.
262 263 264 265 266 |
# File 'lib/extensions.rb', line 262 def data # Note: We do not add the block size or null terminator here, since it will # be blockified later. "\x01" + [@loops & 0xFFFF].pack('S<') end |