Class: Lolita::Configuration::Report

Inherits:
Object
  • Object
show all
Defined in:
lib/lolita-report/configuration/report.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(dbi, title = nil, &block) ⇒ Report

Returns a new instance of Report.

Raises:

  • (ArgumentError)


11
12
13
14
15
16
17
18
19
# File 'lib/lolita-report/configuration/report.rb', line 11

def initialize(dbi,title=nil, &block)
  
  @dbi=dbi
  @column_names=[]
  @title=title
  self.instance_eval(&block) if block_given?
  raise ArgumentError, "Report must have title" unless @title
  set_default_values
end

Instance Attribute Details

#column_names(*args) ⇒ Object



25
26
27
28
29
30
# File 'lib/lolita-report/configuration/report.rb', line 25

def column_names *args
  if args && args.any?
    @column_names=args
  end
  @column_names
end

Class Method Details

.formatsObject



56
57
58
# File 'lib/lolita-report/configuration/report.rb', line 56

def formats
  [:xls]
end

Instance Method Details

#file_name(ext) ⇒ Object



36
37
38
# File 'lib/lolita-report/configuration/report.rb', line 36

def file_name(ext)
  "#{@file_base_name||"#{self.name}"}_#{Time.now.strftime("%Y%m%d%H%M%S")}.#{ext}"
end

#klassObject



40
41
42
43
44
45
46
47
# File 'lib/lolita-report/configuration/report.rb', line 40

def klass
  @klass||=if self.class_name
    Lolita::DBI::Base.new(self.class_name.constantize)
  else
    @dbi
  end
  @klass
end

#report_controllerObject



21
22
23
# File 'lib/lolita-report/configuration/report.rb', line 21

def report_controller
  @controller || ::DefaultReport
end

#save_in_file?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/lolita-report/configuration/report.rb', line 32

def save_in_file?
  !!@file_base_name
end