class Origami::XRef::Subsection

Class representing a cross-reference subsection. A subsection contains a continute set of XRef.

Attributes

range[R]

Public Class Methods

new(start, entries = []) click to toggle source

Creates a new XRef subsection.

start

The number of the first object referenced in the subsection.

entries

An array of XRef.

# File lib/origami/xreftable.rb, line 138
def initialize(start, entries = [])
    @entries = entries.dup
    @range = Range.new(start, start + entries.size - 1)
end

Public Instance Methods

[](no) click to toggle source

Returns XRef associated with a given object.

no

The Object number.

# File lib/origami/xreftable.rb, line 171
def [](no)
    @entries[no - @range.begin]
end
each(&b) click to toggle source

Processes each XRef in the subsection.

# File lib/origami/xreftable.rb, line 178
def each(&b)
    @entries.each(&b)
end
each_with_number() { |entry, next| ... } click to toggle source

Processes each XRef in the subsection, passing the XRef and the object number to the block.

# File lib/origami/xreftable.rb, line 185
def each_with_number
    return enum_for(__method__) { self.size } unless block_given?

    counter = @range.to_enum
    @entries.each do |entry|
        yield(entry, counter.next)
    end
end
has_object?(no) click to toggle source

Returns whether this subsection contains information about a particular object.

no

The Object number.

# File lib/origami/xreftable.rb, line 163
def has_object?(no)
    @range.include?(no)
end
size() click to toggle source

The number of entries in the subsection.

# File lib/origami/xreftable.rb, line 197
def size
    @entries.size
end
to_s() click to toggle source

Outputs self into PDF code.

# File lib/origami/xreftable.rb, line 204
def to_s
    section = "#{@range.begin} #{@range.end - @range.begin + 1}" + EOL
    @entries.each do |xref|
        section << xref.to_s
    end

    section
end