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

Parameters:

  • args (Hash)


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

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

Instance Method Details

- (Boolean) build

Returns:

  • (Boolean)


44
45
46
47
48
49
# File 'lib/batch_load/import/namespaces/simple_interpreter.rb', line 44

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

- (Integer) build_namespaces

Returns:

  • (Integer)


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

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