Skip to content

Commit

Permalink
Table initializer block style example
Browse files Browse the repository at this point in the history
  • Loading branch information
viguini committed Feb 2, 2011
1 parent 0e0e51d commit ec26723
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
22 changes: 22 additions & 0 deletions manual/table/style.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# encoding: utf-8
#
# We've seen how to apply styles to a selection of cells by setting the
# individual properties. Another option is to use the <code>style</code> method
#
# <code>style</code> lets us define multiple properties at once with a hash. It
# also accepts a block that will be called for each cell and can be used for
# some complex styling.
#
require File.expand_path(File.join(File.dirname(__FILE__),
%w[.. example_helper]))

filename = File.basename(__FILE__).gsub('.rb', '.pdf')
Prawn::Example.generate(filename) do
table [[""] * 8] * 8 do
cells.style(:width => 24, :height => 24)

cells.style do |c|
c.background_color = ((c.row + c.column) % 2).zero? ? '000000' : 'ffffff'
end
end
end
3 changes: 2 additions & 1 deletion manual/table/table.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
]
],
["Initializer Block", [ "basic_block",
"filtering"
"filtering",
"style"
]
]
]
Expand Down

0 comments on commit ec26723

Please sign in to comment.