Class: CSV2StringsCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/csvconverter/commands/csv2strings_command.rb

Instance Method Summary collapse

Methods inherited from Command

#csv_download

Instance Method Details

#csv2strings(filename = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/csvconverter/commands/csv2strings_command.rb', line 16

def csv2strings(filename = nil)
  unless filename || options.has_key?('filename')
    say "No value provided for required options '--filename'"
    help("csv2strings")
    exit
  end

  filename ||= options['filename']
  if options['fetch']
    say "Downloading file from Google Drive"
    filename = invoke :csv_download, nil, {"gd_filename" => filename}
    exit unless filename
  end

  unless options.has_key?('langs')
    say "No value provided for required options '--langs'"
    help("csv2strings")
    exit
  end

  args = options.dup
  args.delete(:langs)
  args.delete(:filename)
  converter = CSV2Strings.new(filename, options[:langs], args)
  say converter.csv_to_dotstrings
end