Class: Eco::API::UseCases::DefaultCases::CodesToTagsCase

Inherits:
Common::Loaders::UseCase show all
Defined in:
lib/eco/api/usecases/default_cases/codes_to_tags_case.rb

Instance Attribute Summary

Attributes inherited from Common::Loaders::CaseBase

#usecase

Attributes included from Language::AuxiliarLogger

#logger

Instance Method Summary collapse

Methods inherited from Common::Loaders::UseCase

#initialize, type, #type

Methods inherited from Common::Loaders::CaseBase

#name, name_only_once!

Methods inherited from Common::Loaders::Base

<=>, created_at, #initialize, #name, 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

#codes_to_tagsObject



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/eco/api/usecases/default_cases/codes_to_tags_case.rb', line 5

def codes_to_tags
  raise "You have not defined a tagtree for the organisation" unless session.tagtree
  csv_table = Eco::CSV.read(input_file)

  csv_table.add_column("ecoPortalTag").tap do |csv_table|
    csv_table.each do |row|
      row["ecoPortalTag"] = to_tag(row[codes_column])
    end

    File.open(output_file, "w") {|fd| fd << csv_table.to_csv}
  end
end

#main(session, options, usecase) ⇒ Object



18
19
20
21
# File 'lib/eco/api/usecases/default_cases/codes_to_tags_case.rb', line 18

def main(session, options, usecase)
  options[:end_get] = false
  codes_to_tags
end