Class: DPTM6::PDF::Object
- Inherits:
-
Object
- Object
- DPTM6::PDF::Object
- Defined in:
- lib/dptm6/pdf.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#data ⇒ Object
Returns the value of attribute data.
-
#num ⇒ Object
readonly
Returns the value of attribute num.
-
#pdf ⇒ Object
readonly
Returns the value of attribute pdf.
Instance Method Summary collapse
-
#initialize(pdf, num) ⇒ Object
constructor
A new instance of Object.
- #move_to(pdf, num) ⇒ Object
- #replace_pagenum(hash) ⇒ Object
- #to_string ⇒ Object
- #write ⇒ Object
Constructor Details
#initialize(pdf, num) ⇒ Object
Returns a new instance of Object.
134 135 136 137 138 |
# File 'lib/dptm6/pdf.rb', line 134 def initialize(pdf, num) @pdf = pdf @num = num read end |
Instance Attribute Details
#data ⇒ Object
Returns the value of attribute data.
132 133 134 |
# File 'lib/dptm6/pdf.rb', line 132 def data @data end |
#num ⇒ Object (readonly)
Returns the value of attribute num.
131 132 133 |
# File 'lib/dptm6/pdf.rb', line 131 def num @num end |
#pdf ⇒ Object (readonly)
Returns the value of attribute pdf.
131 132 133 |
# File 'lib/dptm6/pdf.rb', line 131 def pdf @pdf end |
Instance Method Details
#move_to(pdf, num) ⇒ Object
146 147 148 149 150 |
# File 'lib/dptm6/pdf.rb', line 146 def move_to(pdf, num) @pdf = pdf @num = num self end |
#replace_pagenum(hash) ⇒ Object
160 161 162 163 164 |
# File 'lib/dptm6/pdf.rb', line 160 def replace_pagenum(hash) hash.each do |key,num| @data[/#{key}\s++(\d++)\s++\d++\s++R/,1] = num.to_s end end |
#to_string ⇒ Object
140 141 142 143 144 |
# File 'lib/dptm6/pdf.rb', line 140 def to_string return @data if (@num == 0 && @data =~ /%PDF/) "#{@num} #{0} obj\n" << @data << "endobj\n" end |
#write ⇒ Object
152 153 154 155 156 157 158 |
# File 'lib/dptm6/pdf.rb', line 152 def write fp = @pdf.fp pos = fp.pos fp.write(to_string) len = fp.pos - pos @pdf.xref << [pos, len, @num] end |