Class: Processor

Inherits:
Object
  • Object
show all
Defined in:
lib/makesheets/processor.rb

Overview

Maps the matched data into the original base file

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Processor

Returns a new instance of Processor.



10
11
12
13
14
15
16
17
18
# File 'lib/makesheets/processor.rb', line 10

def initialize(options)
    @infile = options[:infile]
    @outfile = options[:outfile] || make_desti_file_name
    @source_sht = options[:sheet] || 0
    @skiprows = options[:skiprows] || 0
    @readrows = options[:readrows]
    @shtcol = options[:column]
    @prefix = options[:prefix]
end

Instance Method Details

#processObject

Executes the process



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/makesheets/processor.rb', line 29

def process
    puts "[Info]: Process initiated..."
    @source = ExcelReader.new(@infile, @source_sht, @skiprows, 
                              @readrows, @shtcol)
    unless column_exists? # Validates if the makesheet column exists

        begin
            raise ColumnNotFoundError.new(@shtcol, @infile)
        rescue => e
            puts "#{e.column} column does not exist in #{e.filename}!!!"
        end
        exit
    end
    @source.read
    ExcelWriter.new(@outfile, @source, @shtcol, @prefix).write
end