Class: Import::Namespaces::SimpleInterpreter

Inherits:
BatchLoad::Import
  • Object
show all
Defined in:
lib/batch_load/import/namespaces/simple_interpreter.rb

Instance Method Summary (collapse)

Constructor Details

- (SimpleInterpreter) initialize(**args)

Returns a new instance of SimpleInterpreter



4
5
6
# File 'lib/batch_load/import/namespaces/simple_interpreter.rb', line 4

def initialize(**args)
  super(args)
end

Instance Method Details

- (Object) build



41
42
43
44
45
46
# File 'lib/batch_load/import/namespaces/simple_interpreter.rb', line 41

def build
  if valid?
    build_namespaces
    @processed = true
  end
end

- (Object) build_namespaces



8
9
10
11
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
# File 'lib/batch_load/import/namespaces/simple_interpreter.rb', line 8

def build_namespaces
  @total_data_lines = 0
  i = 0

  namespaces = {};

  # loop throw rows
  csv.each do |row|
    i += 1

    parse_result = BatchLoad::RowParse.new
    parse_result.objects[:namespaces] = []

    @processed_rows[i] = parse_result

    begin
      namespace_attributes = {
        institution: row["institution"],
        name: row["name"],
        short_name: row["short_name"],
        verbatim_short_name: row["verbatim_short_name"]
      };

      namespace = Namespace.new(namespace_attributes)
      parse_result.objects[:namespaces].push namespace
      @total_data_lines += 1 if namespace.present?
    # rescue TODO: THIS IS A GENERATED STUB, it does not function
    end
  end

  @total_lines = i
end