Class: Origami::Reference
- Inherits:
-
Object
- Object
- Origami::Reference
- Includes:
- Object
- Defined in:
- lib/origami/reference.rb,
lib/origami/obfuscation.rb
Overview
Class representing a Reference Object. Reference are like symbolic links pointing to a particular object into the file.
Constant Summary collapse
- TOKENS =
:nodoc:
[ "(\\d+)" + WHITESPACES + "(\\d+)" + WHITESPACES + "R" ]
- REGEXP_TOKEN =
Regexp.new(TOKENS.first, Regexp::MULTILINE)
- @@regexp =
Regexp.new(WHITESPACES + TOKENS.first + WHITESPACES)
Instance Attribute Summary collapse
-
#refgen ⇒ Object
Returns the value of attribute refgen.
-
#refno ⇒ Object
Returns the value of attribute refno.
Attributes included from Object
#file_offset, #generation, #no, #objstm_offset, #parent
Class Method Summary collapse
-
.parse(stream) ⇒ Object
:nodoc:.
Instance Method Summary collapse
-
#<=>(ref) ⇒ Object
:nodoc.
-
#eql?(ref) ⇒ Boolean
:nodoc.
-
#hash ⇒ Object
:nodoc:.
-
#initialize(refno, refgen) ⇒ Reference
constructor
A new instance of Reference.
- #real_type ⇒ Object
- #solve ⇒ Object
-
#to_a ⇒ Object
Returns a Ruby array with the object number and the generation this reference is pointing to.
- #to_obfuscated_str ⇒ Object
-
#to_s ⇒ Object
:nodoc:.
-
#value ⇒ Object
Returns self.
Methods included from Object
#copy, #export, #indirect_parent, #is_indirect?, #logicalize, #logicalize!, #pdf, #pdf_version_required, #post_build, #pre_build, #reference, #resolve_all_references, #set_indirect, #set_pdf, #size, skip_until_next_obj, #to_o, #type, typeof, #xrefs
Constructor Details
#initialize(refno, refgen) ⇒ Reference
Returns a new instance of Reference.
45 46 47 |
# File 'lib/origami/reference.rb', line 45 def initialize(refno, refgen) @refno, @refgen = refno, refgen end |
Instance Attribute Details
#refgen ⇒ Object
Returns the value of attribute refgen.
43 44 45 |
# File 'lib/origami/reference.rb', line 43 def refgen @refgen end |
#refno ⇒ Object
Returns the value of attribute refno.
43 44 45 |
# File 'lib/origami/reference.rb', line 43 def refno @refno end |
Class Method Details
.parse(stream) ⇒ Object
:nodoc:
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/origami/reference.rb', line 49 def self.parse(stream) #:nodoc: offset = stream.pos if stream.scan(@@regexp).nil? raise InvalidReferenceError, "Bad reference to indirect objet format" end refno = stream[2].to_i refgen = stream[4].to_i ref = Reference.new(refno,refgen) ref.file_offset = offset ref end |
Instance Method Details
#<=>(ref) ⇒ Object
:nodoc
91 92 93 |
# File 'lib/origami/reference.rb', line 91 def <=>(ref) #:nodoc self.to_a <=> ref.to_a end |
#eql?(ref) ⇒ Boolean
:nodoc
83 84 85 |
# File 'lib/origami/reference.rb', line 83 def eql?(ref) #:nodoc ref.is_a?(Reference) and ref.refno == @refno and ref.refgen == @refgen end |
#hash ⇒ Object
:nodoc:
87 88 89 |
# File 'lib/origami/reference.rb', line 87 def hash #:nodoc: self.to_a.hash end |
#solve ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/origami/reference.rb', line 66 def solve pdfdoc = self.pdf if pdfdoc.nil? raise InvalidReferenceError, "Not attached to any PDF" end target = pdfdoc.get_object(self) if target.nil? raise InvalidReferenceError, "Cannot resolve reference : #{self.to_s}" end target end |
#to_a ⇒ Object
Returns a Ruby array with the object number and the generation this reference is pointing to.
98 99 100 |
# File 'lib/origami/reference.rb', line 98 def to_a [@refno, @refgen] end |
#to_obfuscated_str ⇒ Object
165 166 167 168 169 |
# File 'lib/origami/obfuscation.rb', line 165 def refstr = refno.to_s + Obfuscator.junk_spaces + refgen.to_s + Obfuscator.junk_spaces + "R" super(refstr) end |
#to_s ⇒ Object
:nodoc:
102 103 104 |
# File 'lib/origami/reference.rb', line 102 def to_s #:nodoc: super("#{@refno} #{@refgen} R") end |
#value ⇒ Object
Returns self.
109 110 111 |
# File 'lib/origami/reference.rb', line 109 def value self end |