Class: PDF::Reader::LZW::StringTable
- Inherits:
-
Object
- Object
- PDF::Reader::LZW::StringTable
- Defined in:
- lib/pdf/reader/lzw.rb
Overview
stores de pairs code => string
Instance Attribute Summary collapse
-
#string_table_pos ⇒ Object
readonly
: Integer.
Instance Method Summary collapse
-
#[](key) ⇒ Object
if code less than 258 return fixed string : (Integer) -> String?.
-
#add(string) ⇒ Object
: (String) -> void.
-
#initialize ⇒ StringTable
constructor
: () -> void.
Constructor Details
#initialize ⇒ StringTable
: () -> void
75 76 77 78 79 |
# File 'lib/pdf/reader/lzw.rb', line 75 def initialize @data = Hash.new #: Hash[Integer, String] # The initial code @string_table_pos = 258 #: Integer end |
Instance Attribute Details
#string_table_pos ⇒ Object (readonly)
: Integer
72 73 74 |
# File 'lib/pdf/reader/lzw.rb', line 72 def string_table_pos @string_table_pos end |
Instance Method Details
#[](key) ⇒ Object
if code less than 258 return fixed string : (Integer) -> String?
83 84 85 86 87 88 89 |
# File 'lib/pdf/reader/lzw.rb', line 83 def [](key) if key > 257 @data[key] else key.chr end end |
#add(string) ⇒ Object
: (String) -> void
92 93 94 95 |
# File 'lib/pdf/reader/lzw.rb', line 92 def add(string) @data.store(@string_table_pos, string) @string_table_pos += 1 end |