Class: HexaPDF::XRefSection::Entry

Inherits:
Struct
  • Object
show all
Defined in:
lib/hexapdf/xref_section.rb

Overview

One entry of a cross-reference section or stream.

An entry has the attributes type, oid, gen, pos and objstm and can be created like this:

Entry.new(type, oid, gen, pos, objstm)   -> entry

The type attribute can be:

:free

Denotes a free entry.

:in_use

A used entry that resides in the body of the PDF file. The pos attribute defines the position in the file at which the object can be found.

:compressed

A used entry that resides in an object stream. The objstm attribute contains the reference to the object stream in which the object can be found and the pos attribute contains the index into the object stream.

Objects in an object stream always have a generation number of 0!

See: PDF2.0 s7.5.4, s7.5.8

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#genObject

Returns the value of attribute gen

Returns:

  • (Object)

    the current value of gen



73
74
75
# File 'lib/hexapdf/xref_section.rb', line 73

def gen
  @gen
end

#objstmObject

Returns the value of attribute objstm

Returns:

  • (Object)

    the current value of objstm



73
74
75
# File 'lib/hexapdf/xref_section.rb', line 73

def objstm
  @objstm
end

#oidObject

Returns the value of attribute oid

Returns:

  • (Object)

    the current value of oid



73
74
75
# File 'lib/hexapdf/xref_section.rb', line 73

def oid
  @oid
end

#posObject

Returns the value of attribute pos

Returns:

  • (Object)

    the current value of pos



73
74
75
# File 'lib/hexapdf/xref_section.rb', line 73

def pos
  @pos
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



73
74
75
# File 'lib/hexapdf/xref_section.rb', line 73

def type
  @type
end

Instance Method Details

#compressed?Boolean

Returns:

  • (Boolean)


82
83
84
# File 'lib/hexapdf/xref_section.rb', line 82

def compressed?
  type == :compressed
end

#free?Boolean

Returns:

  • (Boolean)


74
75
76
# File 'lib/hexapdf/xref_section.rb', line 74

def free?
  type == :free
end

#in_use?Boolean

Returns:

  • (Boolean)


78
79
80
# File 'lib/hexapdf/xref_section.rb', line 78

def in_use?
  type == :in_use
end

#to_sObject



86
87
88
89
90
91
92
# File 'lib/hexapdf/xref_section.rb', line 86

def to_s
  case type
  when :free then "xref #{oid},#{gen} type=free"
  when :in_use then "xref #{oid},#{gen} type=normal pos=#{pos}"
  when :compressed then "xref #{oid},#{gen} type=compressed objstm=#{objstm},0 index=#{pos}"
  end
end