Class: TrueandcoAnalytics::ApplicationReport
- Inherits:
-
Object
- Object
- TrueandcoAnalytics::ApplicationReport
- Defined in:
- lib/trueandco_analytics/common/reports/application_report.rb
Direct Known Subclasses
Constant Summary collapse
- AVAILABLE_FORMATS =
%w(csv arr).freeze
- DEFAULT_FORMAT =
AVAILABLE_FORMATS[0]
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(format = nil, date_start = nil, date_end = nil) ⇒ ApplicationReport
constructor
A new instance of ApplicationReport.
Constructor Details
permalink #initialize(format = nil, date_start = nil, date_end = nil) ⇒ ApplicationReport
Returns a new instance of ApplicationReport.
7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/trueandco_analytics/common/reports/application_report.rb', line 7 def initialize(format = nil, date_start = nil, date_end = nil) format ||= DEFAULT_FORMAT @format = format unless format_available? raise ArgumentError, I18n.t("trueandco_analytics.error.argument.unknown_format") end date_start = date_start.kind_of?(DateTime) ? date_start : DateTime.new(1970,1,1,0,0,0) date_end = date_end.kind_of?(DateTime) ? date_end : DateTime.now date_end += 1.days arr = source_data(date_start, date_end) @data = send("to_#{format}", arr) end |
Class Method Details
permalink .descendants ⇒ Object
[View source]
33 34 35 |
# File 'lib/trueandco_analytics/common/reports/application_report.rb', line 33 def self.descendants ObjectSpace.each_object(Class).select { |klass| klass < self } end |
permalink .formats ⇒ Object
[View source]
21 22 23 |
# File 'lib/trueandco_analytics/common/reports/application_report.rb', line 21 def self.formats AVAILABLE_FORMATS end |
permalink .reports ⇒ Object
[View source]
25 26 27 |
# File 'lib/trueandco_analytics/common/reports/application_report.rb', line 25 def self.reports self.subclasses.map{ |name| name.to_s.sub(/TrueandcoAnalytics::/,'').underscore } end |
permalink .subclasses ⇒ Object
[View source]
29 30 31 |
# File 'lib/trueandco_analytics/common/reports/application_report.rb', line 29 def self.subclasses self.descendants end |