Class: Eco::API::UseCases::OozeCases::ExportRegisterCase

Inherits:
Eco::API::UseCases::OozeSamples::RegisterExportCase show all
Defined in:
lib/eco/api/usecases/ooze_cases/export_register_case.rb

Overview

Use case to export a register into a CSV

Constant Summary

Constants included from Eco::API::UseCases::OozeSamples::Helpers::Filters

Eco::API::UseCases::OozeSamples::Helpers::Filters::FILTER_TIME_FORMAT

Instance Attribute Summary

Attributes inherited from Eco::API::UseCases::OozeSamples::RegisterExportCase

#options, #session, #target, #usecase

Attributes included from Language::AuxiliarLogger

#logger

Instance Method Summary collapse

Methods inherited from Eco::API::UseCases::OozeSamples::RegisterExportCase

batch_size

Methods included from Eco::API::UseCases::OozeSamples::Helpers::Filters

#date_range_filter, #days, #daystart, #field_key_name, #midnight, #previous_sunday, #set_time, #sunday, #tags_filter, #this_monday, #to_date_filter, #today, #weeks

Methods included from Eco::API::UseCases::OozeSamples::Helpers::Shortcuts

#bracked_regex, #clean_question, #is_number?, #non_letters_regex, #normalize_string, #object_reference, #same_string?, #simplify_string, #titleize, #to_i

Methods inherited from Common::Loaders::UseCase

cli, cli!, #cli_apply!, #initialize, type, #type

Methods inherited from Common::Loaders::CaseBase

#name, name_only_once!

Methods inherited from Common::Loaders::Base

<=>, created_at, #initialize, set_created_at!

Methods included from Common::ClassHelpers

#class_resolver, #descendants, #descendants?, #inheritable_attrs, #inheritable_class_vars, #inherited, #instance_variable_name, #new_class, #resolve_class, #to_constant

Methods included from Language::AuxiliarLogger

#log

Constructor Details

This class inherits a constructor from Eco::API::Common::Loaders::UseCase

Instance Method Details

#filtersObject



24
25
26
27
28
29
# File 'lib/eco/api/usecases/ooze_cases/export_register_case.rb', line 24

def filters
  [].tap do |fltrs|
    %i[any all].each {|mode| fltrs << build_tags_filter(mode)}
    %i[created_at updated_at].each {|key| fltrs << build_range_filter(key)}
  end.compact
end

#main(session, options, usecase) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/eco/api/usecases/ooze_cases/export_register_case.rb', line 7

def main(session, options, usecase)
  super(session, options, usecase) do
    # Save the File
    CSV.open(filename, "w") do |csv|
      csv << exportable_register.header(refresh: true)
      exportable_register.each(as_values: true) do |values|
        csv << values
      end
    end
  end
end

#process_ooze(ooz) ⇒ Object



19
20
21
22
# File 'lib/eco/api/usecases/ooze_cases/export_register_case.rb', line 19

def process_ooze(ooz)
  exportable_register.add_ooze(ooz)
  exportable_register.header
end