Class: TrueandcoAnalytics::Cli::Report
- Inherits:
-
Object
- Object
- TrueandcoAnalytics::Cli::Report
- Includes:
- Modules::Info
- Defined in:
- lib/trueandco_analytics/console/cli/report.rb
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(args) ⇒ Report
constructor
A new instance of Report.
Methods included from Modules::Info
#error_message, #info, #result
Constructor Details
#initialize(args) ⇒ Report
Returns a new instance of Report.
6 7 8 9 10 |
# File 'lib/trueandco_analytics/console/cli/report.rb', line 6 def initialize(args) @args = args @report_args = (Struct.new(:name, :format, :datetime_start, :datetime_end, :path)).new @report_args.name = args[0] end |
Instance Method Details
#execute ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/trueandco_analytics/console/cli/report.rb', line 12 def execute need_generate_report = true OptionParser.new do |opts| opts. = trans('help.need_help') # Info opts.on_tail("-h", "--help", trans('help.about_help')) do need_generate_report = false info(opts) info(trans('help.description').gsub('\n', "\n")) end # Args opts.on("-fValue", "--format=Value", 'format') do |value| @report_args.format = value end opts.on("-sValue", "--datetime_start=Value", 'datetime_strat') do |value| @report_args.datetime_strat = value end opts.on("-eValue", "--datetime_end=Value", 'datetime_end') do |value| @report_args.datetime_end = value end opts.on("-pValue", "--path=Value", 'path') do |value| @report_args.path = value end opts.parse! end if need_generate_report TrueandcoAnalytics::ReportC::Generate.new(report_args.to_h).execute end end |