Class: SheetFiller::Filler

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/sheet_filler/filler.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sheet_filepath, sheet_fields, output, type) ⇒ Filler

Returns a new instance of Filler.



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/sheet_filler/filler.rb', line 16

def initialize(sheet_filepath, sheet_fields, output, type)
  parser =
    case File.extname(sheet_filepath)
    when ".pdf"
      Pdf::Wrapper.new(sheet_filepath, output)
    else
      Doc::Wrapper.new(sheet_filepath, output, type)
    end
  sheet_data = SheetFiller::SheetData.new(sheet_fields)
  @form = Form.new(parser, sheet_data)
end

Class Method Details

.run(data, sheet_data, output_path) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/sheet_filler/filler.rb', line 8

def self.run(data, sheet_data, output_path)
  sheet_file = sheet_data["sheet_file"]
  output_path << File.extname(sheet_file)
  filler = Filler.new(sheet_file,
    sheet_data["sheet_fields"], output_path, sheet_data["filling_type"])
  filler.fill_form(data)
end