Class: Cure::Export::BaseProcessor

Inherits:
Object
  • Object
show all
Includes:
Log
Defined in:
lib/cure/export/base_processor.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Log

#log_debug, #log_error, #log_info, #log_trace, #log_warn

Constructor Details

#initialize(named_range, opts) ⇒ BaseProcessor

Returns a new instance of BaseProcessor.



14
15
16
17
18
19
20
# File 'lib/cure/export/base_processor.rb', line 14

def initialize(named_range, opts)
  @named_range = named_range
  @opts = opts
  @limit_rows = opts.fetch(:limit_rows, nil)

  @processed = 0
end

Instance Attribute Details

#named_rangeObject (readonly)

Returns the value of attribute named_range.



12
13
14
# File 'lib/cure/export/base_processor.rb', line 12

def named_range
  @named_range
end

Instance Method Details

#cleanupObject

Raises:

  • (NotImplementedError)


38
39
40
# File 'lib/cure/export/base_processor.rb', line 38

def cleanup
  raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end

#process(_row) ⇒ Object

Parameters:

  • (Hash)

Raises:

  • (NotImplementedError)


30
31
32
# File 'lib/cure/export/base_processor.rb', line 30

def process(_row)
  raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end

#process_row(row) ⇒ Object

Parameters:

  • (Hash)


23
24
25
26
27
# File 'lib/cure/export/base_processor.rb', line 23

def process_row(row)
  process(row) unless @limit_rows && @limit_rows <= @processed

  @processed += 1
end

#setupObject

Raises:

  • (NotImplementedError)


34
35
36
# File 'lib/cure/export/base_processor.rb', line 34

def setup
  raise NotImplementedError, "#{self.class} has not implemented method '#{__method__}'"
end