Class: Excelsed

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file_path, scan_mappings, output_dir, file_name: 'output') ⇒ Excelsed

Returns a new instance of Excelsed.



4
5
6
7
8
9
10
11
12
# File 'lib/excelsed.rb', line 4

def initialize file_path, scan_mappings, output_dir, file_name: 'output'
  @file_path = file_path
  @scan_mappings = scan_mappings
  @output_dir = output_dir
  @tmp_dir = "#{output_dir}/tmp"
  @file_name = file_name

  FileUtils.mkdir_p(tmp_dir)
end

Instance Attribute Details

#file_nameObject (readonly)

Returns the value of attribute file_name.



2
3
4
# File 'lib/excelsed.rb', line 2

def file_name
  @file_name
end

#file_pathObject (readonly)

Returns the value of attribute file_path.



2
3
4
# File 'lib/excelsed.rb', line 2

def file_path
  @file_path
end

#output_dirObject (readonly)

Returns the value of attribute output_dir.



2
3
4
# File 'lib/excelsed.rb', line 2

def output_dir
  @output_dir
end

#scan_mappingsObject (readonly)

Returns the value of attribute scan_mappings.



2
3
4
# File 'lib/excelsed.rb', line 2

def scan_mappings
  @scan_mappings
end

#tmp_dirObject (readonly)

Returns the value of attribute tmp_dir.



2
3
4
# File 'lib/excelsed.rb', line 2

def tmp_dir
  @tmp_dir
end

Instance Method Details

#performObject



14
15
16
17
18
19
20
21
22
# File 'lib/excelsed.rb', line 14

def perform
  perform_unzip
  sed_mappings
  export_result

  {file_path: "#{output_dir}/#{file_name}.xlsx"}
ensure
  FileUtils.rm_rf(tmp_dir)
end