Class: Prune::Elements::Stream

Inherits:
Base
  • Object
show all
Defined in:
lib/prune/elements/stream.rb

Instance Attribute Summary collapse

Attributes inherited from Base

#document

Instance Method Summary collapse

Methods inherited from Base

#reference, #register

Methods included from Functions

#mm_to_pt, #pt_to_mm

Methods included from PObjects

pa, pd, ph, pl, pn, ps

Constructor Details

#initialize(document) ⇒ Stream

Initialize.



9
10
11
12
13
14
15
16
17
# File 'lib/prune/elements/stream.rb', line 9

def initialize(document)
  super(document)
  # Set dictionary.
  @content = pd(pn(:Length) => 0)
  # Set stream.
  @stream = ps
  # Register element to document.
  register
end

Instance Attribute Details

#streamObject (readonly)

Returns the value of attribute stream.



6
7
8
# File 'lib/prune/elements/stream.rb', line 6

def stream
  @stream
end

Instance Method Details

#to_sObject

Convert stream to String.



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/prune/elements/stream.rb', line 20

def to_s
  # Update length of the stream.
  @content[pn(:Length)] = @stream.length
  # Convert to String.
  out = []
  out << "#{@element_id} #{@revision} obj"
  out << @content.to_s
  out << @stream.to_s
  out << "endobj"
  return out.join(LF)
end