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

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

Overview

stores de pairs code => string

Instance Attribute Summary collapse

Attributes inherited from ObjectHash

#default, #pdf_version, #sec_handler, #trailer

Instance Method Summary collapse

Methods inherited from Hash

#version

Methods inherited from ObjectHash

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

Constructor Details

#initializeStringTable

Returns a new instance of StringTable.



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

def initialize
  super
  @string_table_pos = 258 #initial code
end

Instance Attribute Details

#string_table_posObject (readonly)

:nodoc:



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

def string_table_pos
  @string_table_pos
end

Instance Method Details

#[](key) ⇒ Object

if code less than 258 return fixed string



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

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

#add(string) ⇒ Object



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

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