Class: Prune::Elements::Base
- Inherits:
-
Object
- Object
- Prune::Elements::Base
- Includes:
- Prune::Errors, Functions, PObjects
- Defined in:
- lib/prune/elements/base.rb
Direct Known Subclasses
Catalog, Font, FontDescriptor, Info, Outlines, Page, Pages, ProcedureSets, Stream
Instance Attribute Summary collapse
-
#document ⇒ Object
readonly
Returns the value of attribute document.
Instance Method Summary collapse
-
#initialize(document) ⇒ Base
constructor
Initialize.
-
#reference ⇒ Object
Get reference id of the element.
-
#register ⇒ Object
Register element to document.
-
#to_s ⇒ Object
Convert element to String.
Methods included from Functions
Methods included from PObjects
Constructor Details
#initialize(document) ⇒ Base
Initialize.
13 14 15 16 17 18 19 20 |
# File 'lib/prune/elements/base.rb', line 13 def initialize(document) @document = document @element_id = 0 @revision = 0 @content = nil @stream = nil @registered = false end |
Instance Attribute Details
#document ⇒ Object (readonly)
Returns the value of attribute document.
10 11 12 |
# File 'lib/prune/elements/base.rb', line 10 def document @document end |
Instance Method Details
#reference ⇒ Object
Get reference id of the element.
33 34 35 36 |
# File 'lib/prune/elements/base.rb', line 33 def reference raise ObjectNotRegisteredError unless @registered "#{@element_id} #{@revision} R" end |
#register ⇒ Object
Register element to document.
39 40 41 42 43 44 45 |
# File 'lib/prune/elements/base.rb', line 39 def register unless @registered @element_id = @document.elements.size + 1 @document.elements << self @registered = true end end |
#to_s ⇒ Object
Convert element to String.
23 24 25 26 27 28 29 30 |
# File 'lib/prune/elements/base.rb', line 23 def to_s raise ElementNotRegisteredError unless @registered out = [] out << "%d %d obj" % [@element_id, @revision] out << @content.to_s out << "endobj" return out.join(LF) end |