Class: Prawn::DocumentBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/prawn/document_builder.rb,
lib/prawn/document_builder/layout.rb,
lib/prawn/document_builder/command.rb,
lib/prawn/document_builder/constructs/path_construct.rb,
lib/prawn/document_builder/modifications/path_modification.rb,
lib/prawn/document_builder/constructs/flowing_text_construct.rb,
lib/prawn/document_builder/modifications/layout_modification.rb

Defined Under Namespace

Classes: Command, FlowingTextConstruct, Layout, LayoutModification, PathConstruct, PathModification

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDocumentBuilder

Returns a new instance of DocumentBuilder.



8
9
10
# File 'lib/prawn/document_builder.rb', line 8

def initialize
  @commands = []
end

Instance Attribute Details

#commandsObject

Returns the value of attribute commands.



12
13
14
# File 'lib/prawn/document_builder.rb', line 12

def commands
  @commands
end

Instance Method Details

#compileObject



14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/prawn/document_builder.rb', line 14

def compile
  document = ::Prawn::Document.new
  layout   = ::Prawn::DocumentBuilder::Layout.new(self, document)

  original_commands = commands.dup

  while c = commands.shift
    c.execute(document, layout)
  end

  self.commands = original_commands

  document
end