Class: JotPDF::Core::Writer
- Inherits:
-
Object
- Object
- JotPDF::Core::Writer
- Defined in:
- lib/jot_pdf/core.rb
Instance Attribute Summary collapse
-
#io ⇒ Object
readonly
Returns the value of attribute io.
-
#objects ⇒ Object
readonly
Returns the value of attribute objects.
-
#offset ⇒ Object
readonly
Returns the value of attribute offset.
Instance Method Summary collapse
- #<<(data) ⇒ Object
- #finish_section ⇒ Object
-
#initialize(io) ⇒ Writer
constructor
A new instance of Writer.
- #new_object ⇒ Object
- #update_object_entry(object_ref) ⇒ Object
Constructor Details
#initialize(io) ⇒ Writer
Returns a new instance of Writer.
27 28 29 30 31 32 33 34 |
# File 'lib/jot_pdf/core.rb', line 27 def initialize(io) @objects = [ CrossReferenceTableEntry.default, ] @section = [0] @io = io @offset = 0 end |
Instance Attribute Details
#io ⇒ Object (readonly)
Returns the value of attribute io.
25 26 27 |
# File 'lib/jot_pdf/core.rb', line 25 def io @io end |
#objects ⇒ Object (readonly)
Returns the value of attribute objects.
25 26 27 |
# File 'lib/jot_pdf/core.rb', line 25 def objects @objects end |
#offset ⇒ Object (readonly)
Returns the value of attribute offset.
25 26 27 |
# File 'lib/jot_pdf/core.rb', line 25 def offset @offset end |
Instance Method Details
#<<(data) ⇒ Object
57 58 59 60 61 62 |
# File 'lib/jot_pdf/core.rb', line 57 def <<(data) s = data.to_s @io << s @offset += s.bytesize self end |
#finish_section ⇒ Object
51 52 53 54 55 |
# File 'lib/jot_pdf/core.rb', line 51 def finish_section result = @section.dup @section.clear result end |
#new_object ⇒ Object
36 37 38 39 40 |
# File 'lib/jot_pdf/core.rb', line 36 def new_object number = @objects.size @objects << CrossReferenceTableEntry.default ObjectRef.new(number:, generation: 0) end |
#update_object_entry(object_ref) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/jot_pdf/core.rb', line 42 def update_object_entry(object_ref) @section << object_ref.number @objects[object_ref.number] = CrossReferenceTableEntry.new( generation: object_ref.generation, offset: @offset, usage: :in_use, ) end |