Class: File
- Inherits:
-
Object
- Object
- File
- Defined in:
- lib/magic/core/file.rb
Class Method Summary collapse
-
.magic(path, flags = Magic::NONE) ⇒ Object
call-seq: File.magic( path ) -> string, array or nil.
-
.mime(path) ⇒ Object
call-seq: File.mime( path ) -> string, array or nil.
-
.type(path) ⇒ Object
call-seq: File.type( path ) -> string, array or nil.
Instance Method Summary collapse
-
#magic ⇒ Object
call-seq: File.magic( path ) -> string, array or nil.
-
#mime ⇒ Object
call-seq: File.mime( path ) -> string, array or nil.
-
#type ⇒ Object
call-seq: File.type( path ) -> string, array or nil.
Class Method Details
.magic(path, flags = Magic::NONE) ⇒ Object
call-seq:
File.magic( path ) -> string, array or nil
Returns
Example:
See also: File::mime and File::type
40 41 42 43 44 45 46 47 |
# File 'lib/magic/core/file.rb', line 40 def magic(path, flags = Magic::NONE) path = path.path if path.respond_to?(:path) path ||= path.to_path if path.respond_to?(:to_path) path ||= path.to_s Magic.open(flags) {|mgc| mgc.file(path) } rescue Magic::Error end |
Instance Method Details
#magic ⇒ Object
call-seq:
File.magic( path ) -> string, array or nil
Returns
Example:
See also: File#mime and File#type
88 89 90 |
# File 'lib/magic/core/file.rb', line 88 def magic self.class.magic(self) end |
#mime ⇒ Object
call-seq:
File.mime( path ) -> string, array or nil
Returns
Example:
See also: File#magic and File#type
102 103 104 |
# File 'lib/magic/core/file.rb', line 102 def mime self.class.mime(self) end |
#type ⇒ Object
call-seq:
File.type( path ) -> string, array or nil
Returns
Example:
See also: File#magic and File#mime
116 117 118 |
# File 'lib/magic/core/file.rb', line 116 def type self.class.type(self) end |