Sha256: dc07a78795d35c1f544c40ef57b02d2ba501cb8710f1854d5f4b22da333c1204
Contents?: true
Size: 739 Bytes
Versions: 5
Compression:
Stored size: 739 Bytes
Contents
# frozen_string_literal: true module OrganizeFiles # file_sorter.rb class FileOrder TYPES = { images: ['.jpg', '.jpeg', '.png', '.gif'], documents: ['.pdf', '.docx', '.txt', '.md'], audio: ['.mp3', '.wav', '.flac'], videos: ['.mp4', '.mkv', '.avi'], archives: ['.zip', '.tar', '.rar', '.gz'] }.freeze def initialize(file) @file = file end def categorize file_ext = File.extname(file) category = TYPES.find { |_key, exts| exts.include?(file_ext) } case category when :images then 'Pictures' when :documents then 'Documents' when :audio then 'Music' when :videos then 'Videos' else 'Archives' end end end end
Version data entries
5 entries across 5 versions & 1 rubygems