lib/reportbuilder/table.rb in reportbuilder-0.1.0 vs lib/reportbuilder/table.rb in reportbuilder-0.2.0

- old
+ new

@@ -17,12 +17,12 @@ # | 3 | | Paul | ab-3 | | # ----------------------------------------- # | 4 | London |George | ab-4 | # ----------------------------------------- class Table - @@n=1 - # :nodoc: + @@n=1 # :nodoc: + DEFAULT_OPTIONS={ :header => [], :name => nil } # Array of headers @@ -34,10 +34,11 @@ # Create a new table. # Options: :name, :header # Use: # table=ReportBuilder::Table.new(:header =>["var1","var2"]) def initialize(opts=Hash.new) + raise ArgumentError,"opts should be a Hash" if !opts.is_a? Hash opts=DEFAULT_OPTIONS.merge opts if opts[:name].nil? @name= "Table #{@@n}" @@n+=1 else @@ -55,10 +56,11 @@ # Adds a horizontal rule # table.add_hr def add_hr @rows.push(:hr) end + alias_method :add_horizontal_line, :add_hr # Adds a rowspan on a cell # table.add_row(["a",table.rowspan("b",2)]) def rowspan(data,n) Rowspan.new(data,n) end @@ -91,15 +93,15 @@ @max_cols[i]= size if @max_cols[i].nil? or @max_cols[i] < size end } } end - def to_rb_text(generator) + def to_reportbuilder_text(generator) require 'reportbuilder/table/textgenerator' table_generator=ReportBuilder::Table::TextGenerator.new( generator, self) table_generator.generate end - def to_rb_html(generator) + def to_reportbuilder_html(generator) require 'reportbuilder/table/htmlgenerator' table_generator=ReportBuilder::Table::HtmlGenerator.new(generator, self) table_generator.generate end