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

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

Overview

stores de pairs code => string

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeStringTable

Returns a new instance of StringTable.



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

def initialize
  @data = Hash.new
  @string_table_pos = 258 #initial code
end

Instance Attribute Details

#string_table_posObject (readonly)

Returns the value of attribute string_table_pos.



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

def string_table_pos
  @string_table_pos
end

Instance Method Details

#[](key) ⇒ Object

if code less than 258 return fixed string



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

def [](key)
  if key > 257
    @data[key]
  else
    key.chr
  end
end

#add(string) ⇒ Object



83
84
85
86
# File 'lib/pdf/reader/lzw.rb', line 83

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