Class: Pdfrb::Model::Type::ObjectStream

Inherits:
Cos::Stream show all
Defined in:
lib/pdfrb/model/type/object_stream.rb

Overview

Compressed object stream (s7.5.7). /Type /ObjStm, /N count, /First byte offset of first object, /Extends parent ObjStm.

Instance Attribute Summary

Attributes inherited from Cos::Stream

#stream

Attributes inherited from Object

#document, #gen, #oid, #value

Instance Method Summary collapse

Methods inherited from Cos::Stream

#decoded_stream, #encoded_stream=, #initialize

Methods inherited from Cos::Dictionary

#[], #[]=, arlington_available?, arlington_default, arlington_key_to_symbol, arlington_loaded_for?, arlington_mark_loaded, arlington_object, arlington_one_type_to_ruby, arlington_required?, arlington_types_to_ruby, arlington_version, define_field, define_field_from_arlington, #delete, #each, each_field, #each_raw, #empty?, field, #initialize, #key?, #keys, lookup_type, own_fields, #pdf_type, register_type, type_map, #validate

Methods inherited from Object

#==, define_type, #deref, #indirect?, #initialize, #must_be_indirect?, #pdf_type, pdf_type

Constructor Details

This class inherits a constructor from Pdfrb::Model::Cos::Stream

Instance Method Details

#compressed_countObject



22
23
24
# File 'lib/pdfrb/model/type/object_stream.rb', line 22

def compressed_count
  number_of_objects || 0
end

#each_object_referenceObject



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/pdfrb/model/type/object_stream.rb', line 26

def each_object_reference
  return enum_for(:each_object_reference) unless block_given?
  return unless number_of_objects && first_byte_offset

  stream_data = decoded_stream
  return unless stream_data

  offset = 0
  number_of_objects.times do
    space_idx = stream_data.index(" ", offset)
    return if space_idx.nil?

    oid = stream_data[offset...space_idx].to_i

    newline_idx = stream_data.index(/\s/, space_idx + 1)
    return if newline_idx.nil?

    byte_offset = stream_data[(space_idx + 1)...newline_idx].to_i

    yield oid, byte_offset + first_byte_offset
    offset = newline_idx + 1
  end
end

#extendsObject



15
# File 'lib/pdfrb/model/type/object_stream.rb', line 15

def extends; self[:Extends]; end

#filterObject



16
# File 'lib/pdfrb/model/type/object_stream.rb', line 16

def filter; self[:Filter]; end

#first_byte_offsetObject



14
# File 'lib/pdfrb/model/type/object_stream.rb', line 14

def first_byte_offset; self[:First]; end

#has_parent?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/pdfrb/model/type/object_stream.rb', line 18

def has_parent?
  !!extends
end

#number_of_objectsObject



13
# File 'lib/pdfrb/model/type/object_stream.rb', line 13

def number_of_objects; self[:N]; end

#typeObject



12
# File 'lib/pdfrb/model/type/object_stream.rb', line 12

def type; self[:Type]; end