Class: Ckeditor::Utils::ContentTypeDetector
- Inherits:
-
Object
- Object
- Ckeditor::Utils::ContentTypeDetector
- Defined in:
- lib/ckeditor/utils/content_type_detector.rb
Constant Summary collapse
- EMPTY_CONTENT_TYPE =
'inode/x-empty'.freeze
- DEFAULT_CONTENT_TYPE =
'application/octet-stream'.freeze
Instance Method Summary collapse
-
#detect ⇒ Object
content type detection strategy:.
-
#initialize(file_path) ⇒ ContentTypeDetector
constructor
A new instance of ContentTypeDetector.
Constructor Details
#initialize(file_path) ⇒ ContentTypeDetector
Returns a new instance of ContentTypeDetector.
10 11 12 |
# File 'lib/ckeditor/utils/content_type_detector.rb', line 10 def initialize(file_path) @file_path = file_path end |
Instance Method Details
#detect ⇒ Object
content type detection strategy:
-
empty file: returns ‘inode/x-empty’
-
nonempty file: if the file is not empty then returns the content type using file command
-
invalid file: file command raises error and returns ‘application/octet-stream’
20 21 22 |
# File 'lib/ckeditor/utils/content_type_detector.rb', line 20 def detect empty_file? ? EMPTY_CONTENT_TYPE : content_type_from_file_command end |