Module: Typor

Defined in:
lib/typor.rb,
lib/typor/magic.rb,
lib/typor/version.rb

Overview

Typor Module

Defined Under Namespace

Modules: Magic

Constant Summary collapse

VERSION =

Version

'1.0.0'

Class Method Summary collapse

Class Method Details

.data(d) ⇒ String

Get Data Type: Determine MIME Type of Data String.

Parameters:

  • d (String)

    Data String

Returns:

  • (String)

    MIME Type



27
28
29
# File 'lib/typor.rb', line 27

def self.data d
	(Magic.detect_magic(d) || []).try :first
end

.file(f) ⇒ String

Get File Type: Determines MIME Type of Local File.

Parameters:

  • f (String)

    Path to a File

Returns:

  • (String)

    MIME Type



19
20
21
# File 'lib/typor.rb', line 19

def self.file f
	(Magic.detect_magic(File.read(f)) || []).try :first
end