Sha256: 3dede5abb874e19a3a789860c5e563d8f04f56552fe5f5d5d190f9aef476e9b0
Contents?: true
Size: 909 Bytes
Versions: 4
Compression:
Stored size: 909 Bytes
Contents
# frozen_string_literal: true module OrganizeFiles # file_sorter.rb class FileOrder TYPES = { images: ['.jpg', '.jpeg', '.png', '.gif', '.avif'], documents: ['.pdf', '.docx', '.txt', '.md', '.json', '.csv', '.xls', '.xlsx', '.ppt', '.pptx'], audio: ['.mp3', '.wav', '.flac'], videos: ['.mp4', '.mkv', '.avi'], archives: ['.zip', '.tar', '.rar', '.gz', '.7z', '.iso'], apks: ['.apk'] }.freeze def initialize(file) @file = file end def categorize file_ext = File.extname(@file) category = TYPES.find { |_key, exts| exts.include?(file_ext) } return 'Archives' unless category case category[0] when :images then 'Pictures' when :documents then 'Documents' when :audio then 'Music' when :videos then 'Videos' when :apks then 'Apks' else 'Archives' end end end end
Version data entries
4 entries across 4 versions & 1 rubygems