Class: ZPNG::Chunk::ZTXT

Inherits:
ZPNG::Chunk show all
Defined in:
lib/zpng/chunk.rb

Instance Attribute Summary collapse

Attributes inherited from ZPNG::Chunk

#crc, #data, #idx, #size, #type

Instance Method Summary collapse

Methods inherited from ZPNG::Chunk

#crc_ok?, #export, #export_data, from_stream

Constructor Details

#initialize(*args) ⇒ ZTXT

Returns a new instance of ZTXT.



232
233
234
235
236
237
238
# File 'lib/zpng/chunk.rb', line 232

def initialize *args
  super
  @keyword,@comp_method,@text = data.unpack('Z*Ca*')
  if @text
    @text = Zlib::Inflate.inflate(@text)
  end
end

Instance Attribute Details

#comp_methodObject

Returns the value of attribute comp_method.



231
232
233
# File 'lib/zpng/chunk.rb', line 231

def comp_method
  @comp_method
end

#keywordObject

Returns the value of attribute keyword.



231
232
233
# File 'lib/zpng/chunk.rb', line 231

def keyword
  @keyword
end

#textObject

Returns the value of attribute text.



231
232
233
# File 'lib/zpng/chunk.rb', line 231

def text
  @text
end

Instance Method Details

#inspectObject



239
240
241
242
243
244
245
246
247
# File 'lib/zpng/chunk.rb', line 239

def inspect
  super.sub(/ *>$/,'') + ", " +
    (instance_variables-[:@type, :@crc, :@data, :@size]).
    map do |var|
      t = instance_variable_get(var).to_s
      t = t[0..10] + "..." if t.size > 10
      "#{var.to_s.tr('@','')}=#{t}"
    end.join(", ") + ">"
end