Class: Origami::XRef::Subsection
- Inherits:
-
Object
- Object
- Origami::XRef::Subsection
- Defined in:
- lib/origami/xreftable.rb
Overview
Class representing a cross-reference subsection. A subsection contains a continute set of XRef.
Constant Summary collapse
- @@regexp =
Regexp.new("(\\d+) (\\d+)" + WHITESPACES + "(\\r?\\n|\\r\\n?)")
Instance Attribute Summary collapse
-
#range ⇒ Object
readonly
Returns the value of attribute range.
Class Method Summary collapse
-
.parse(stream) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#[](no) ⇒ Object
Returns XRef associated with a given object.
-
#each(&b) ⇒ Object
Processes each XRef in the subsection.
-
#has_object?(no) ⇒ Boolean
Returns whether this subsection contains information about a particular object.
-
#initialize(start, entries = []) ⇒ Subsection
constructor
Creates a new XRef subsection.
-
#to_s ⇒ Object
Outputs self into PDF code.
Constructor Details
#initialize(start, entries = []) ⇒ Subsection
Creates a new XRef subsection.
- start
-
The number of the first object referenced in the subsection.
- entries
-
An array of XRef.
143 144 145 146 147 148 |
# File 'lib/origami/xreftable.rb', line 143 def initialize(start, entries = []) @entries = entries.dup @range = Range.new(start, start + entries.size - 1) end |
Instance Attribute Details
#range ⇒ Object (readonly)
Returns the value of attribute range.
136 137 138 |
# File 'lib/origami/xreftable.rb', line 136 def range @range end |
Class Method Details
.parse(stream) ⇒ Object
:nodoc:
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 |
# File 'lib/origami/xreftable.rb', line 150 def self.parse(stream) #:nodoc: if stream.scan(@@regexp).nil? raise InvalidXRefSubsectionError, "Bad subsection format" end start = stream[1].to_i size = stream[2].to_i xrefs = [] size.times do xrefs << XRef.parse(stream) end XRef::Subsection.new(start, xrefs) end |
Instance Method Details
#[](no) ⇒ Object
Returns XRef associated with a given object.
- no
-
The Object number.
179 180 181 |
# File 'lib/origami/xreftable.rb', line 179 def [](no) @entries[no - @range.begin] end |
#each(&b) ⇒ Object
Processes each XRef in the subsection.
186 187 188 |
# File 'lib/origami/xreftable.rb', line 186 def each(&b) @entries.each(&b) end |
#has_object?(no) ⇒ Boolean
Returns whether this subsection contains information about a particular object.
- no
-
The Object number.
171 172 173 |
# File 'lib/origami/xreftable.rb', line 171 def has_object?(no) @range.include?(no) end |