Thanks Henrik! That worked great! I didn't think of the hash
merge...duh!
Only change from your pastie example is that in my Rails app the
options variable must begin
with lower case (i.e., not be a constant), otherwise I get a 'dynamic
constant assignment (SyntaxError)'. so...(simplified example)...
TOP_HEADER_OPTIONS = { :background_color => 'CC0000',
:font_style => :bold,
:colspan => 2 }
...should be...
top_header_options = { :background_color => 'CC0000',
:font_style => :bold,
:colspan => 2 }
Here's the full pastie, just in case it becomes unavailable later...
<<
require "rubygems"
require "prawn"
require "prawn/layout"
TOP_HEADER_OPTIONS = {
:background_color => 'CC0000',
:align => :center,
:font_style => :bold,
:colspan => 2
}
BOTTOM_HEADER_OPTIONS = {
:background_color => '0000CC',
:align => :center,
:font_style => :italic
}
tbody = [
[{ :text => "A" }.merge(TOP_HEADER_OPTIONS), { :text => "B" }.merge
(TOP_HEADER_OPTIONS)],
[{ :text => "A1" }.merge(BOTTOM_HEADER_OPTIONS), { :text =>
"A2" }.merge(BOTTOM_HEADER_OPTIONS), { :text => "B1" }.merge
(BOTTOM_HEADER_OPTIONS), { :text => "B2" }.merge
(BOTTOM_HEADER_OPTIONS)],
["x", "y", "z", "w"]
]
Prawn::Document.new do
table tbody
render_file '/tmp/table.pdf'
end
`open /tmp/table.pdf` # OS X
>>
On Dec 2, 12:35 am, Henrik Nyh <
hen...@nyh.se> wrote: