Class: D3MPQ::Command::CSV

Inherits:
Object
  • Object
show all
Defined in:
lib/d3_mpq/commands/csv.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ CSV

Returns a new instance of CSV.



7
8
9
10
11
12
13
14
15
16
# File 'lib/d3_mpq/commands/csv.rb', line 7

def initialize(options = {})
  @options = options
  @klass = @options[:klass]

  FileUtils.mkdir_p csv_path

  klass = eval("D3MPQ::CSVGenerator::#{@klass}")
  generator = klass.new(generator_params)
  generator.write
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/d3_mpq/commands/csv.rb', line 5

def options
  @options
end

Instance Method Details

#csv_nameObject



26
27
28
# File 'lib/d3_mpq/commands/csv.rb', line 26

def csv_name
  @options[:csv_name] || @klass.to_s
end

#csv_pathObject



42
43
44
# File 'lib/d3_mpq/commands/csv.rb', line 42

def csv_path
  options[:csv_path]
end

#generator_paramsObject



18
19
20
# File 'lib/d3_mpq/commands/csv.rb', line 18

def generator_params
  { :files => input_path, :output_path => output_path }
end

#input_pathObject



38
39
40
# File 'lib/d3_mpq/commands/csv.rb', line 38

def input_path
  options[:csv_input]
end

#localeObject



30
31
32
# File 'lib/d3_mpq/commands/csv.rb', line 30

def locale
  ".#{options[:locale]}" if options[:locale] && !options[:locale].empty?
end

#output_pathObject



22
23
24
# File 'lib/d3_mpq/commands/csv.rb', line 22

def output_path
  "#{csv_path}/#{csv_name}#{patch}#{locale}.csv"
end

#patchObject



34
35
36
# File 'lib/d3_mpq/commands/csv.rb', line 34

def patch
  ".#{options[:patch]}" if options[:patch] && !options[:patch].empty?
end