Class: PDFBeads::PDFBuilder::XObj

Inherits:
Object
  • Object
show all
Defined in:
lib/pdfbeads/pdfdoc.rb

Constant Summary collapse

@@next_id =
1

Instance Method Summary collapse

Constructor Details

#initialize(d = {}, stream = nil) ⇒ XObj

Returns a new instance of XObj.



51
52
53
54
55
# File 'lib/pdfbeads/pdfdoc.rb', line 51

def initialize(d = {}, stream = nil)
  reinit(d, stream)
  @id = @@next_id
  @@next_id += 1
end

Instance Method Details

#addToDict(key, value) ⇒ Object



76
77
78
# File 'lib/pdfbeads/pdfdoc.rb', line 76

def addToDict(key, value)
  @d[key] = value
end

#dictLengthObject



96
97
98
# File 'lib/pdfbeads/pdfdoc.rb', line 96

def dictLength
  @d.length
end

#getFromDict(key) ⇒ Object



84
85
86
# File 'lib/pdfbeads/pdfdoc.rb', line 84

def getFromDict(key)
  @d[key]
end

#getIDObject



92
93
94
# File 'lib/pdfbeads/pdfdoc.rb', line 92

def getID
  @id
end

#hasInDict(key) ⇒ Object



80
81
82
# File 'lib/pdfbeads/pdfdoc.rb', line 80

def hasInDict(key)
  @d.has_key? key
end

#reinit(d = {}, stream = nil) ⇒ Object



69
70
71
72
73
74
# File 'lib/pdfbeads/pdfdoc.rb', line 69

def reinit(d = {}, stream = nil)
  @d = PDFBuilder::Dict.new(d)
  @stream = stream
  @stream.to_binary if stream.kind_of? String
  @d['Length'] = stream.length.to_s unless stream.nil?
end

#removeFromDict(key) ⇒ Object



88
89
90
# File 'lib/pdfbeads/pdfdoc.rb', line 88

def removeFromDict(key)
  @d.delete(key)
end

#to_sObject



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/pdfbeads/pdfdoc.rb', line 57

def to_s()
  s = ''
  s << @d.to_s
  unless @stream.nil?
    s << "stream\n"
    s << @stream
    s << "\nendstream\n"
  end
  s << "endobj\n"
  return s
end