Class: Report

Inherits:
Object
  • Object
show all
Defined in:
app/reports/report.rb

Defined Under Namespace

Modules: CallStatistics, ChannelRevenue Classes: AccountsPayableCommand, AccountsReceivableCommand, BaseCommand, CustomerPerformance, CustomerPerformanceCommand, InventoryPlanningCommand, PhoneQueueReportCommand, ProjectMetric, StatusTimelineReport

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Report

Returns a new instance of Report.



4
5
6
7
8
9
# File 'app/reports/report.rb', line 4

def initialize(options)
  @errors = []
  @results = nil
  @logger = options.delete(:logger) || Rails.logger
  @options = options
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



2
3
4
# File 'app/reports/report.rb', line 2

def options
  @options
end

#resultsObject (readonly)

Returns the value of attribute results.



2
3
4
# File 'app/reports/report.rb', line 2

def results
  @results
end

Class Method Details

.build(options) ⇒ Object



19
20
21
22
23
# File 'app/reports/report.rb', line 19

def self.build(options)
  report_class = "#{options[:report_type]}_report"
  report_klass = report_class.classify.constantize
  report_klass.new(options)
end

.parametersObject



15
16
17
# File 'app/reports/report.rb', line 15

def self.parameters
  {}
end

.parse_date(o) ⇒ Object



25
26
27
28
# File 'app/reports/report.rb', line 25

def self.parse_date(o)
  return o if o.is_a? Date
  Date.strptime(o, '%Y-%m-%d') rescue nil
end

Instance Method Details

#report_keyObject



11
12
13
# File 'app/reports/report.rb', line 11

def report_key
  self.class.to_s.tableize.singularize
end