Creates an instance of +Magic::Database+ using given database file and flags
# File lib/magic/database.rb, line 7 def initialize(*args) options = args.last.is_a?(Hash) ? args.pop : {} # extract options database = options.delete(:database) open(*args) load(database) end
Determine type of given string
# File lib/magic/database.rb, line 41 def buffer(string) result = Api.magic_buffer(@magic_set, string, string.bytesize) if result.null? raise Exception, error else result.get_string(0) end end
Closes the database
# File lib/magic/database.rb, line 21 def close Api.magic_close(@magic_set) end
Returns the last error occured
# File lib/magic/database.rb, line 51 def error Api.magic_error(@magic_set) end
Determine type of a file at given path
# File lib/magic/database.rb, line 31 def file(filename) result = Api.magic_file(@magic_set, filename.to_s) if result.null? raise Exception, error else result.get_string(0) end end
Sets the flags
# File lib/magic/database.rb, line 56 def flags=(*flags) @flags = calculate_flags(*flags) Api.magic_setflags(@magic_set, @flags) end
Generated with the Darkfish Rdoc Generator 2.