DocumentServer/OnlineEditorsExample/OnlineEditorsExampleRuby/app/models/file_utility.rb
2015-04-29 19:10:50 +03:00

31 lines
613 B
Ruby

class FileUtility
@@exts_document = %w(.docx .doc .odt .rtf .txt .html .htm .mht .pdf .djvu .fb2 .epub .xps)
@@exts_spreadsheet = %w(.xls .xlsx .ods .csv)
@@exts_presentation = %w(.ppt .pptx .odp)
class << self
def get_file_type(file_name)
ext = File.extname(file_name)
if @@exts_document.include? ext
return 'text'
end
if @@exts_spreadsheet.include? ext
return 'spreadsheet'
end
if @@exts_presentation.include? ext
return 'presentation'
end
'text'
end
end
end