Class: Cleaner

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

Instance Method Summary collapse

Constructor Details

#initialize(options_list, to_clean_list, not_converted_list) ⇒ Cleaner

Returns a new instance of Cleaner.



2
3
4
5
6
7
8
9
10
11
# File 'lib/bvwack/cleaner.rb', line 2

def initialize(options_list, to_clean_list, not_converted_list)
  @options_list       = options_list
  @to_clean_list      = to_clean_list
  @not_converted_list = not_converted_list
  if @options_list[:base_dir]
    @clean_dir = "#{@options_list[:base_dir]}/bvwack-back"
  else
    @clean_dir = DEFAULT_CLEAN_BASE_DIR
  end
end

Instance Method Details

#clean_upObject



13
14
15
16
17
18
19
20
21
# File 'lib/bvwack/cleaner.rb', line 13

def clean_up
  if @to_clean_list.length > 0
    key      = @to_clean_list.pop
    filename = @not_converted_list[key]
    dirname  = File.dirname(@not_converted_list[key])
    `mkdir -p "#{@clean_dir}/#{dirname}" && mv "#{filename}" "#{@clean_dir}/#{filename}"`
    #puts "I would have run clean_up"
  end
end