class Processor
Assembles all the required classes and processes¶ ↑
Reads from Excel file¶ ↑
Maps the matched data into the original base file¶ ↑
Public Class Methods
new(options)
click to toggle source
# 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
Public Instance Methods
process()
click to toggle source
Executes the process
# 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
Private Instance Methods
column_exists?()
click to toggle source
# File lib/makesheets/processor.rb, line 46 def column_exists? @source.headers.include?(@shtcol) end
make_desti_file_name()
click to toggle source
Makes destination file name from source file name
# File lib/makesheets/processor.rb, line 21 def make_desti_file_name folder, file = File.split(@infile) extn = file[-5..-1] new_file = file[0..-6] + '_Result' + extn File.join(folder, new_file) end