Class: Prawn::Commander
- Inherits:
-
Object
- Object
- Prawn::Commander
- Defined in:
- lib/prawn_commander.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#prawn_commands(&block) ⇒ Object
Returns the value of attribute prawn_commands.
-
#prawn_document ⇒ Object
Returns the value of attribute prawn_document.
Instance Method Summary collapse
-
#initialize(prawn_doc = nil, options = {:dry_run => true}) ⇒ Commander
constructor
A new instance of Commander.
- #prawn_command(method, *args, &block) ⇒ Object
- #print_raw_prawn_commands ⇒ Object
- #raw_prawn_commands ⇒ Object
Constructor Details
#initialize(prawn_doc = nil, options = {:dry_run => true}) ⇒ Commander
Returns a new instance of Commander.
5 6 7 8 9 |
# File 'lib/prawn_commander.rb', line 5 def initialize(prawn_doc = nil, = {:dry_run => true}) @prawn_document = prawn_doc @prawn_commands = [] @options = end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
3 4 5 |
# File 'lib/prawn_commander.rb', line 3 def @options end |
#prawn_commands(&block) ⇒ Object
Returns the value of attribute prawn_commands.
3 4 5 |
# File 'lib/prawn_commander.rb', line 3 def prawn_commands @prawn_commands end |
#prawn_document ⇒ Object
Returns the value of attribute prawn_document.
3 4 5 |
# File 'lib/prawn_commander.rb', line 3 def prawn_document @prawn_document end |
Instance Method Details
#prawn_command(method, *args, &block) ⇒ Object
39 40 41 42 43 44 45 46 |
# File 'lib/prawn_commander.rb', line 39 def prawn_command(method, *args, &block) raise "#{method} is not a valid prawn command on a prawn document" if !valid_prawn_command?(method) add_command(method, args.dup, block != nil) # make clone of command to ensure the original is not in any way modified internally by prawn cmd = Marshal.load( Marshal.dump(prawn_commands.last) ) document_execute cmd if prawn_document end |
#print_raw_prawn_commands ⇒ Object
35 36 37 |
# File 'lib/prawn_commander.rb', line 35 def print_raw_prawn_commands puts raw_prawn_commands.join("\n") end |
#raw_prawn_commands ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/prawn_commander.rb', line 19 def raw_prawn_commands raw_commands = [] prawn_commands.each do |command| args = command[:args].size == 1 ? command[:args][0] : command[:args] # arg_str = args arg_str = case args when Array args.map{|a| a.inspect}.join(',') else args end raw_commands << "#{command[:method]} #{arg_str}" end raw_commands end |