| Module | Origami::Object |
| In: |
sources/parser/object.rb
|
| file_offset | [RW] | |
| generation | [RW] | |
| no | [RW] | |
| objstm_offset | [RW] | |
| parent | [RW] |
Compare two objects from their respective numbers.
# File sources/parser/object.rb, line 300
300: def <=>(obj)
301: [@no, @generation] <=> [obj.no, obj.generation]
302: end
Returns the indirect object which contains this object. If the current object is already indirect, returns self.
# File sources/parser/object.rb, line 352
352: def indirect_parent
353: obj = self
354: obj = obj.parent until obj.is_indirect?
355:
356: obj
357: end
Returns whether the objects is indirect, which means that it is not embedded into another object.
# File sources/parser/object.rb, line 307
307: def is_indirect?
308: @indirect
309: end
Generic method called just after the object is finalized. At this time, any indirect object has its own number and generation identifier.
# File sources/parser/object.rb, line 293
293: def post_build
294: self
295: end
Generic method called just before the object is finalized. At this time, no number nor generation allocation has yet been done.
# File sources/parser/object.rb, line 285
285: def pre_build
286: self
287: end
Returns an indirect reference to this object, or a Null object is this object is not indirect.
# File sources/parser/object.rb, line 321
321: def reference
322: unless self.is_indirect?
323: raise InvalidObject, "Cannot reference a direct object"
324: end
325:
326: ref = Reference.new(@no, @generation)
327: ref.parent = self
328:
329: ref
330: end
Sets whether the object is indirect or not. Indirect objects are allocated numbers at build time.
# File sources/parser/object.rb, line 272
272: def set_indirect(dir)
273: unless dir == true or dir == false
274: raise TypeError, "The argument must be boolean"
275: end
276:
277: @indirect = dir
278: self
279: end
# File sources/parser/object.rb, line 383
383: def set_pdf(pdf)
384: if self.is_indirect? then @pdf = pdf
385: else
386: raise InvalidObject, "You cannot set the PDF parent of a direct object"
387: end
388: end
Returns an array of references pointing to the current object.
# File sources/parser/object.rb, line 335
335: def xrefs
336: unless self.is_indirect?
337: raise InvalidObject, "Cannot find xrefs to a direct object"
338: end
339:
340: if self.pdf.nil?
341: raise InvalidObject, "Not attached to any PDF"
342: end
343:
344: thisref = self.reference
345: @pdf.objects.find_all{|obj| obj.is_a?(Reference) and obj.eql?(thisref)}
346: end