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 or array.
-
.mime(path) ⇒ Object
call-seq: File.mime( path ) -> string or array.
-
.type(path) ⇒ Object
call-seq: File.type( path ) -> string or array.
Instance Method Summary collapse
-
#magic ⇒ Object
call-seq: File.magic( path ) -> string or array.
-
#mime ⇒ Object
call-seq: File.mime( path ) -> string or array.
-
#type ⇒ Object
call-seq: File.type( path ) -> string or array.
Class Method Details
.magic(path, flags = Magic::NONE) ⇒ Object
call-seq:
File.magic( path ) -> string or array
Returns
Example:
See also: File::mime and File::type
40 41 42 43 44 45 46 |
# 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 | Magic::ERROR) {|mgc| mgc.file(path) } end |
.mime(path) ⇒ Object
call-seq:
File.mime( path ) -> string or array
Returns
Example:
See also: File::magic and File::type
58 59 60 |
# File 'lib/magic/core/file.rb', line 58 def mime(path) magic(path, Magic::MIME) end |
.type(path) ⇒ Object
call-seq:
File.type( path ) -> string or array
Returns
Example:
See also: File::magic and File::mime
72 73 74 |
# File 'lib/magic/core/file.rb', line 72 def type(path) magic(path, Magic::MIME_TYPE) end |
Instance Method Details
#magic ⇒ Object
call-seq:
File.magic( path ) -> string or array
Returns
Example:
See also: File#mime and File#type
87 88 89 |
# File 'lib/magic/core/file.rb', line 87 def magic self.class.magic(self) end |
#mime ⇒ Object
call-seq:
File.mime( path ) -> string or array
Returns
Example:
See also: File#magic and File#type
101 102 103 |
# File 'lib/magic/core/file.rb', line 101 def mime self.class.mime(self) end |
#type ⇒ Object
call-seq:
File.type( path ) -> string or array
Returns
Example:
See also: File#magic and File#mime
115 116 117 |
# File 'lib/magic/core/file.rb', line 115 def type self.class.type(self) end |