Class: ZPNG::TextChunk

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

Direct Known Subclasses

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

Instance Attribute Summary collapse

Attributes inherited from Chunk

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

Instance Method Summary collapse

Methods inherited from Chunk

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

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



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/zpng/text_chunk.rb', line 5

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?(Fixnum)
        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



23
24
25
# File 'lib/zpng/text_chunk.rb', line 23

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