lib/filemagic.rb in ruby-filemagic-0.5.0 vs lib/filemagic.rb in ruby-filemagic-0.5.1
- old
+ new
@@ -1,6 +1,6 @@
-require 'filemagic.so'
+require 'filemagic/ruby_filemagic'
require 'filemagic/version'
class FileMagic
# Map flag names to their values (:name => Integer).
@@ -41,11 +41,11 @@
# Extract "simple" MIME type.
SIMPLE_RE = %r{([.\w\/-]+)}
@fm = Hash.new { |fm, flags|
- fm.has_key?(key = flags.to_s) ? fm[key] : fm[key] = new(*flags)
+ fm.key?(key = flags.to_s) ? fm[key] : fm[key] = new(*flags)
}
class << self
# Provide a "magic singleton".
@@ -85,9 +85,13 @@
attr_writer :simplified
def simplified?
@simplified
+ end
+
+ def io(io, length = 8)
+ buffer(io.read(length))
end
def inspect
super.insert(-2, closed? ? ' (closed)' : '')
end