summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/util
diff options
context:
space:
mode:
authormarc <[email protected]>2015-07-03 16:58:21 +0200
committermarc <[email protected]>2015-07-03 16:58:21 +0200
commitd7de10ade8d8f28efd0a41963aa263f9ef58ceb4 (patch)
tree8677c3ea89677f395059eef8fd67505d9a792557 /lib/axlsx/util
parentc7c7937dcde9a94f2e5ee0549451b34e410803e0 (diff)
downloadcaxlsx-d7de10ade8d8f28efd0a41963aa263f9ef58ceb4.tar.gz
caxlsx-d7de10ade8d8f28efd0a41963aa263f9ef58ceb4.zip
Extract mime type detection to an utility class
Diffstat (limited to 'lib/axlsx/util')
-rw-r--r--lib/axlsx/util/mime_type_utils.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/axlsx/util/mime_type_utils.rb b/lib/axlsx/util/mime_type_utils.rb
new file mode 100644
index 00000000..3fe2dbbd
--- /dev/null
+++ b/lib/axlsx/util/mime_type_utils.rb
@@ -0,0 +1,11 @@
+module Axlsx
+ # This module defines some utils related with mime type detection
+ module MimeTypeUtils
+ # Detect a file mime type
+ # @param [String] v File path
+ # @return [String] File mime type
+ def self.get_mime_type(v)
+ MimeMagic.by_magic(File.open(v)).to_s
+ end
+ end
+end