Class: Pnjson::Chunk

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

Constant Summary collapse

CRITICAL_CHUNKS_TYPES =
%w( IHDR PLTE IDAT IEND )
ANCILLARY_CHUNKS_TYPES =
%w(bKGD cHRM gAMA hIST iCCP iTXt pHYs sBIT sPLT
sRGB sTER tEXt tIME tRNS zTXt)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Chunk



13
14
15
16
17
18
# File 'lib/pnjson/chunk.rb', line 13

def initialize(options = {})
  @length = options[:length]
  @type   = hex_to_ascii(options[:type])
  @data   = options[:data]
  @crc    = options[:crc]
end

Instance Attribute Details

#crcObject

Returns the value of attribute crc.



6
7
8
# File 'lib/pnjson/chunk.rb', line 6

def crc
  @crc
end

#dataObject

Returns the value of attribute data.



5
6
7
# File 'lib/pnjson/chunk.rb', line 5

def data
  @data
end

#lengthObject

Returns the value of attribute length.



3
4
5
# File 'lib/pnjson/chunk.rb', line 3

def length
  @length
end

#typeObject

Returns the value of attribute type.



4
5
6
# File 'lib/pnjson/chunk.rb', line 4

def type
  @type
end

Instance Method Details

#to_hashObject



20
21
22
23
24
25
26
27
# File 'lib/pnjson/chunk.rb', line 20

def to_hash
  {
    length: @length,
    type: @type,
    data: @data,
    crc: @crc
  }
end