| 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 298
298: def <=>(obj)
299: [@no, @generation] <=> [obj.no, obj.generation]
300: end
Returns the indirect object which contains this object. If the current object is already indirect, returns self.
# File sources/parser/object.rb, line 350
350: def indirect_parent
351: obj = self
352: obj = obj.parent until obj.is_indirect?
353:
354: obj
355: end
Returns whether the objects is indirect, which means that it is not embedded into another object.
# File sources/parser/object.rb, line 305
305: def is_indirect?
306: @indirect
307: 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 291
291: def post_build
292: self
293: 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 283
283: def pre_build
284: self
285: end
Returns an indirect reference to this object, or a Null object is this object is not indirect.
# File sources/parser/object.rb, line 319
319: def reference
320: unless self.is_indirect?
321: raise InvalidObject, "Cannot reference a direct object"
322: end
323:
324: ref = Reference.new(@no, @generation)
325: ref.parent = self
326:
327: ref
328: end
Sets whether the object is indirect or not. Indirect objects are allocated numbers at build time.
# File sources/parser/object.rb, line 270
270: def set_indirect(dir)
271: unless dir == true or dir == false
272: raise TypeError, "The argument must be boolean"
273: end
274:
275: @indirect = dir
276: self
277: end
# File sources/parser/object.rb, line 381
381: def set_pdf(pdf)
382: if self.is_indirect? then @pdf = pdf
383: else
384: raise InvalidObject, "You cannot set the PDF parent of a direct object"
385: end
386: end
Outputs this object into PDF code.
| data: | The object data. |
# File sources/parser/object.rb, line 470
470: def to_s(data)
471:
472: content = ""
473: content << "#{no} #{generation} obj" << EOL if self.is_indirect?
474: content << data
475: content << EOL << "endobj" << EOL if self.is_indirect?
476:
477: content
478: end
Returns an array of references pointing to the current object.
# File sources/parser/object.rb, line 333
333: def xrefs
334: unless self.is_indirect?
335: raise InvalidObject, "Cannot find xrefs to a direct object"
336: end
337:
338: if self.pdf.nil?
339: raise InvalidObject, "Not attached to any PDF"
340: end
341:
342: thisref = self.reference
343: @pdf.objects.find_all{|obj| obj.is_a?(Reference) and obj.eql?(thisref)}
344: end