Shortcut interface for creating Data::Group
Example:
g = Group('mygroup', :data => [[1,2,3],[4,5,6]], :column_names => %w[a b c]) #=> creates a new group named mygroup
# File lib/ruport/data/grouping.rb, line 396 def Group(name,opts={}) Ruport::Data::Group.new(opts.merge(:name => name)) end
Shortcut interface for creating Data::Grouping
Example:
a = Table(%w[a b c], :data => [[1,2,3],[4,5,6]]) b = Grouping(a, :by => "a") #=> creates a new grouping on column "a"
# File lib/ruport/data/grouping.rb, line 385 def Grouping(*args) Ruport::Data::Grouping.new(*args) end
Shortcut interface for creating Data::Tables
Examples:
t = Table(%w[a b c]) #=> creates a new empty table w. cols a,b,c t = Table("a","b","c") #=> creates a new empty table w. cols a,b,c # allows building table inside of block, returns table object t = Table(%w[a b c]) { |t| t << [1,2,3] } # allows loading table from CSV # accepts all Data::Table.load options, including block (yields table,row) t = Table("foo.csv") t = Table("bar.csv", :has_names => false)
# File lib/ruport/data/table.rb, line 928 def Table(*args,&block) table= case(args[0]) when Array opts = args[1] || {} Ruport::Data::Table.new(f={:column_names => args[0]}.merge(opts),&block) when /\.csv/ return Ruport::Data::Table.load(*args,&block) when Hash if file = args[0].delete(:file) return Ruport::Data::Table.load(file,args[0],&block) elsif string = args[0].delete(:string) return Ruport::Data::Table.parse(string,args[0],&block) else return Ruport::Data::Table.new(args[0],&block) end else Ruport::Data::Table.new(:data => [], :column_names => args,&block) end return table end
Generated with the Darkfish Rdoc Generator 2.