Module: HexaPDF::CLI::Usage::ParserExtension
- Defined in:
- lib/hexapdf/cli/usage.rb
Overview
Modifies HexaPDF::Parser to retrieve space used by indirect objects.
Instance Method Summary collapse
-
#initialize ⇒ Object
:nodoc:.
-
#load_compressed_object(xref_entry) ⇒ Object
:nodoc:.
-
#load_object(xref_entry) ⇒ Object
:nodoc:.
-
#parse_indirect_object(offset = nil) ⇒ Object
:nodoc:.
Instance Method Details
#initialize ⇒ Object
:nodoc:
60 61 62 63 |
# File 'lib/hexapdf/cli/usage.rb', line 60 def initialize(*) super @last_size = nil end |
#load_compressed_object(xref_entry) ⇒ Object
:nodoc:
86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/hexapdf/cli/usage.rb', line 86 def load_compressed_object(xref_entry) result = super offsets = @object_stream_data[xref_entry.objstm].instance_variable_get(:@offsets) @last_size = if xref_entry.pos == offsets.size - 1 @object_stream_data[xref_entry.objstm].instance_variable_get(:@tokenizer). io.size - offsets[xref_entry.pos] else offsets[xref_entry.pos + 1] - offsets[xref_entry.pos] end result end |
#load_object(xref_entry) ⇒ Object
:nodoc:
66 67 68 69 70 71 72 73 74 75 |
# File 'lib/hexapdf/cli/usage.rb', line 66 def load_object(xref_entry) super.tap do |obj| if xref_entry.type == :compressed obj.data.size_in_object_stream = @last_size elsif xref_entry.type == :in_use obj.data.size = @last_size end @last_size = nil end end |
#parse_indirect_object(offset = nil) ⇒ Object
:nodoc:
78 79 80 81 82 83 |
# File 'lib/hexapdf/cli/usage.rb', line 78 def parse_indirect_object(offset = nil) real_offset = (offset ? @header_offset + offset : @tokenizer.pos) result = super @last_size = @tokenizer.pos - real_offset result end |