module Rapport::Report::ClassMethods

Attributes

row_data[RW]

Public Instance Methods

column(*args, &block) click to toggle source
# File lib/rapport/report.rb, line 18
def column(*args, &block)
  raise ArgumentError.new("wrong number of arguments (#{args.length} for 1,2, or 3)") unless args.length >= 1 and args.length <= 3
  header = args[0]
  if args.length == 3
    symbol = args[1].to_sym; options = args[2].to_hash
  elsif args.length == 2
    if args[1].is_a?(Symbol)
      symbol = args[1]; options = {}
    else
      symbol = Rapport.format_underscore(header.downcase).to_sym; options = args[1].to_hash
    end
  end
  add_calculator(symbol, options) unless options.nil?
  instance_variable_get(:@columns) << [header, symbol]
end

Private Instance Methods

add_calculator(symbol, options) click to toggle source
# File lib/rapport/report.rb, line 36
def add_calculator(symbol, options)
  instance_variable_get(:@cell_calculators)[symbol] = options
end