Class: PDF::Reader::LZW::StringTable

Inherits:
Hash show all
Defined in:
lib/pdf/reader/lzw.rb

Overview

stores de pairs code => string

Constant Summary

Constants inherited from ObjectHash

ObjectHash::CACHEABLE_TYPES

Instance Attribute Summary collapse

Attributes inherited from ObjectHash

#default, #pdf_version, #trailer

Instance Method Summary collapse

Methods inherited from Hash

#version

Methods inherited from ObjectHash

#cacheable?, #each, #each_key, #each_value, #empty?, #fetch, #has_key?, #has_value?, #keys, #obj_type, #object, #page_references, #size, #stream?, #to_a, #to_s, #values, #values_at

Constructor Details

#initializeStringTable

Returns a new instance of StringTable.



64
65
66
67
# File 'lib/pdf/reader/lzw.rb', line 64

def initialize
  super
  @string_table_pos = 258 #initial code
end

Instance Attribute Details

#string_table_posObject (readonly)

:nodoc:



62
63
64
# File 'lib/pdf/reader/lzw.rb', line 62

def string_table_pos
  @string_table_pos
end

Instance Method Details

#[](key) ⇒ Object

if code less than 258 return fixed string



70
71
72
# File 'lib/pdf/reader/lzw.rb', line 70

def [](key)
  if key > 257 then super else key.chr end
end

#add(string) ⇒ Object



74
75
76
77
# File 'lib/pdf/reader/lzw.rb', line 74

def add(string)
  store(@string_table_pos, string)
  @string_table_pos += 1
end