Class: SheetFiller::Doc::Wrapper

Inherits:
Struct
  • Object
show all
Defined in:
lib/sheet_filler/doc/wrapper.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#form_pathObject

Returns the value of attribute form_path



5
6
7
# File 'lib/sheet_filler/doc/wrapper.rb', line 5

def form_path
  @form_path
end

#output_pathObject

Returns the value of attribute output_path



5
6
7
# File 'lib/sheet_filler/doc/wrapper.rb', line 5

def output_path
  @output_path
end

#typeObject

Returns the value of attribute type



5
6
7
# File 'lib/sheet_filler/doc/wrapper.rb', line 5

def type
  @type
end

Instance Method Details

#fill(data) ⇒ Object



18
19
20
21
22
23
24
25
26
# File 'lib/sheet_filler/doc/wrapper.rb', line 18

def fill(data)
  if type == "fill_form"
    parser.fill_form(data)
  else
    parser.replace(data)
  end
  parser.save(output_path)
  output_path
end

#parse_fields(data) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/sheet_filler/doc/wrapper.rb', line 10

def parse_fields(data)
  if type == "fill_form"
    Parser.fields(form_path).map(&:name)
  else
    data
  end
end

#parserObject



6
7
8
# File 'lib/sheet_filler/doc/wrapper.rb', line 6

def parser
  @parser ||= WordXmlFile.new(form_path)
end