14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/classes/filetypes.rb', line 14
def self.add(ext = nil, type = nil)
unless ext
puts 'please enter the file type\'s extension, with or without the dot.'
ext = gets.strip
end
unless type
puts 'please enter "movie" or "pic" so we know what we\'re working with.'
type = gets.strip
end
ext = ext.to_s.gsub(/[*."]/, '')
type = type.downcase.include?('m') ? 'movie' : 'pic'
puts "opening file \"#{File.dirname(__FILE__)}/filetypes.csv\""
CSV.open("#{File.dirname(__FILE__)}/filetypes.csv", 'a') do |csv|
csv << [ext, type]
end
puts 'New file types registered.'
exit
end
|