Module: Bini::FileMagic

Extended by:
FileMagic
Included in:
FileMagic
Defined in:
lib/bini/filemagic.rb

Overview

A collection of helpers related to file management.

Instance Method Summary collapse

Instance Method Details

#mime_type(file) ⇒ String, Nil

Call the system app ‘file’ to check mimetype.

Parameters:

  • file (String)

    name of the file.

Returns:

  • (String)

    of the mimetypes found

  • (Nil)

    if nothing worked.



10
11
12
13
# File 'lib/bini/filemagic.rb', line 10

def mime_type(file)
  return `file -bk --mime-type "#{file}"`.chomp! if File.exist? file
  return nil
end