Class: Sheetsy::Converter

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, destination, options = {}) ⇒ Converter

Returns a new instance of Converter.



7
8
9
10
11
# File 'lib/sheetsy/converter.rb', line 7

def initialize(source, destination, options = {})
  @source = source
  @destination = destination
  @options = options
end

Instance Attribute Details

#destinationObject (readonly)

Returns the value of attribute destination.



5
6
7
# File 'lib/sheetsy/converter.rb', line 5

def destination
  @destination
end

#optionsObject (readonly)

Returns the value of attribute options.



5
6
7
# File 'lib/sheetsy/converter.rb', line 5

def options
  @options
end

#sourceObject (readonly)

Returns the value of attribute source.



5
6
7
# File 'lib/sheetsy/converter.rb', line 5

def source
  @source
end

Instance Method Details

#debug?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/sheetsy/converter.rb', line 32

def debug?
  @debug ||= options[:debug]
end

#overwrite?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/sheetsy/converter.rb', line 28

def overwrite?
  @overwrite ||= options[:overwrite]
end

#runObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/sheetsy/converter.rb', line 13

def run
  debug "Files found: #{files.count}"

  progress_bar.progress = 0

  FileUtils.mkdir_p(destination) unless File.directory?(destination)

  files.each do |file|
    process_file(file)
    progress_bar.increment
  end

  puts "Conversion complete."
end