Class: ZPNG::TextChunk

Inherits:
Chunk
  • Object
show all
Defined in:
lib/zpng/text_chunk.rb

Direct Known Subclasses

Chunk::ITXT, Chunk::TEXT, Chunk::ZTXT

Constant Summary collapse

INTEGER_CLASS =
Fixnum

Constants inherited from Chunk

Chunk::KNOWN_TYPES, Chunk::VALID_SIZE_RANGE

Instance Attribute Summary collapse

Attributes inherited from Chunk

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

Instance Method Summary collapse

Methods inherited from Chunk

#check, #crc_ok?, #export, #export_data, #fix_crc!, from_stream, #initialize, #valid?

Methods included from DeepCopyable

#deep_copy

Constructor Details

This class inherits a constructor from ZPNG::Chunk

Instance Attribute Details

#keywordObject

Returns the value of attribute keyword.



3
4
5
# File 'lib/zpng/text_chunk.rb', line 3

def keyword
  @keyword
end

#textObject

Returns the value of attribute text.



3
4
5
# File 'lib/zpng/text_chunk.rb', line 3

def text
  @text
end

Instance Method Details

#inspect(verbosity = 10) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/zpng/text_chunk.rb', line 11

def inspect verbosity = 10
  vars = %w'keyword text language translated_keyword cmethod cflag'
  vars -= %w'text translated_keyword' if verbosity <=0
  super.sub(/ *>$/,'') + ", " +
    vars.map do |var|
      t = instance_variable_get("@#{var}")
      unless t.is_a?(INTEGER_CLASS)
        t = t.to_s
        t = t[0..20] + "..." if t.size > 20
      end
      if t.nil? || t == ''
        nil
      else
        "#{var.to_s.tr('@','')}=#{t.inspect}"
      end
    end.compact.join(", ") + ">"
end

#to_hashObject



29
30
31
# File 'lib/zpng/text_chunk.rb', line 29

def to_hash
  { :keyword => keyword, :text => text}
end