Class: Report

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

Overview

Report: report.

Defined Under Namespace

Modules: CallStatistics, ChannelRevenue Classes: AccountsPayableCommand, AccountsReceivableCommand, BaseCommand, CallRecordingGaps, CustomerPerformance, CustomerPerformanceCommand, DailyImportSummary, 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.



6
7
8
9
10
11
# File 'app/reports/report.rb', line 6

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.



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

def options
  @options
end

#resultsObject (readonly)

Returns the value of attribute results.



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

def results
  @results
end

Class Method Details

.build(options) ⇒ Object



21
22
23
24
25
# File 'app/reports/report.rb', line 21

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

.parametersObject



17
18
19
# File 'app/reports/report.rb', line 17

def self.parameters
  {}
end

.parse_date(o) ⇒ Object



27
28
29
30
31
32
33
34
35
# File 'app/reports/report.rb', line 27

def self.parse_date(o)
  return o if o.is_a? Date

  begin
    Date.strptime(o, '%Y-%m-%d')
  rescue StandardError
    nil
  end
end

Instance Method Details

#report_keyObject



13
14
15
# File 'app/reports/report.rb', line 13

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