ruby - How to pack multiple parameter into one -


i use prawn generate pdf. make table, do:

table test_rows(test), :column_widths => [100, 200, 360] , &table_style 

is there way can let me put proc table_style? don't want repeat column_widths , table_style in code.

def table_style   return proc.new{     row(0).font_style = :bold     columns(1..3).align = :center         self.row_colors = ["dddddd", "ffffff"]     self.header = true         } end 

this method appears take 3 arguments: data, options , block. see https://github.com/prawnpdf/prawn/blob/master/lib/prawn/table.rb

if trying store arguments temporary variables re-use in other calls table, can use like:

options = { :column_widths => [100, 200, 360] } table_style = proc.new { ... }  table(data1, options, &table_style) table(data2, options, &table_style) 

Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -