Class: Prawn::DocumentBuilder::Command

Inherits:
Object
  • Object
show all
Defined in:
lib/prawn/document_builder/command.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, params = {}) ⇒ Command

Returns a new instance of Command.



4
5
6
7
# File 'lib/prawn/document_builder/command.rb', line 4

def initialize(name, params={})
  @name    = name
  @params  = params
end

Instance Attribute Details

#boxObject

Returns the value of attribute box.



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

def box
  @box
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#paramsObject

Returns the value of attribute params.



10
11
12
# File 'lib/prawn/document_builder/command.rb', line 10

def params
  @params
end

Instance Method Details

#execute(document, layout) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/prawn/document_builder/command.rb', line 17

def execute(document, layout)
   save_params
   setup
   send(name, document, layout)
   teardown
   restore_params
end

#restore_paramsObject



33
34
35
# File 'lib/prawn/document_builder/command.rb', line 33

def restore_params
  @params = @original_params
end

#save_paramsObject



29
30
31
# File 'lib/prawn/document_builder/command.rb', line 29

def save_params
  @original_params = @params.dup
end

#setupObject



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

def setup
  # stub, replace in your subclasses
end

#teardownObject



25
26
27
# File 'lib/prawn/document_builder/command.rb', line 25

def teardown
  # stub, replace in your subclasses
end