Class: Sheetah::SheetProcessor

Inherits:
Object
  • Object
show all
Includes:
Utils::MonadicResult
Defined in:
lib/sheetah/sheet_processor.rb

Constant Summary

Constants included from Utils::MonadicResult

Utils::MonadicResult::Unit

Instance Method Summary collapse

Methods included from Utils::MonadicResult

#Do, #Failure, #Success

Constructor Details

#initialize(specification) ⇒ SheetProcessor

Returns a new instance of SheetProcessor.



15
16
17
# File 'lib/sheetah/sheet_processor.rb', line 15

def initialize(specification)
  @specification = specification
end

Instance Method Details

#call(*args, **opts) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/sheetah/sheet_processor.rb', line 19

def call(*args, **opts)
  messenger = Messaging::Messenger.new

  result = Do() do
    Backends.open(*args, **opts) do |sheet|
      row_processor = build_row_processor(sheet, messenger)

      sheet.each_row do |row|
        yield row_processor.call(row)
      end
    end
  end

  handle_result(result, messenger)
end