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( object ) -> string or array File.magic( string ) -> string or array.
-
.mime(path) ⇒ Object
call-seq: File.mime( string ) -> string or array.
-
.type(path) ⇒ Object
call-seq: File.type( string ) -> string or array.
Instance Method Summary collapse
-
#magic ⇒ Object
call-seq: File.magic -> string or array.
-
#mime ⇒ Object
call-seq: File.mime -> string or array.
-
#type ⇒ Object
call-seq: File.type -> string or array.
Class Method Details
.magic(path, flags = Magic::NONE) ⇒ Object
call-seq:
File.magic( object ) -> string or array
File.magic( string ) -> string or array
See also: File::mime and File::type
12 13 14 |
# File 'lib/magic/core/file.rb', line 12 def magic(path, flags = Magic::NONE) Magic.open(flags) {|mgc| mgc.file(path) } end |
.mime(path) ⇒ Object
call-seq:
File.mime( string ) -> string or array
See also: File::magic and File::type
22 23 24 |
# File 'lib/magic/core/file.rb', line 22 def mime(path) magic(path, Magic::MIME) end |
.type(path) ⇒ Object
call-seq:
File.type( string ) -> string or array
See also: File::magic and File::mime
32 33 34 |
# File 'lib/magic/core/file.rb', line 32 def type(path) magic(path, Magic::MIME_TYPE) end |
Instance Method Details
#magic ⇒ Object
call-seq:
File.magic -> string or array
See also: File#mime and File#type
43 44 45 |
# File 'lib/magic/core/file.rb', line 43 def magic self.class.magic(self) end |
#mime ⇒ Object
call-seq:
File.mime -> string or array
See also: File#magic and File#type
53 54 55 |
# File 'lib/magic/core/file.rb', line 53 def mime self.class.mime(self) end |
#type ⇒ Object
call-seq:
File.type -> string or array
See also: File#magic and File#mime
63 64 65 |
# File 'lib/magic/core/file.rb', line 63 def type self.class.type(self) end |