Skip to content

Commit

Permalink
code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
minad committed Jan 23, 2011
1 parent bbe2490 commit 061cadd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/mimemagic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def self.add(type, options)
# * <i>type</i>: The mime type to remove. All associated extensions and magic are removed too.
def self.remove(type)
EXTENSIONS.delete_if {|ext, t| t == type }
MAGIC.delete_if { |t, m| t == type }
MAGIC.delete_if {|t, m| t == type }
TYPES.delete(type)
end

Expand All @@ -50,7 +50,7 @@ def video?; mediatype == 'video'; end

# Returns true if type is child of parent type
def child_of?(parent)
child?(type, parent)
MimeMagic.child?(type, parent)
end

# Get string list of file extensions
Expand All @@ -67,7 +67,7 @@ def comment
def self.by_extension(ext)
ext = ext.to_s.downcase
mime = ext[0..0] == '.' ? EXTENSIONS[ext[1..-1]] : EXTENSIONS[ext]
mime ? new(mime) : nil
mime && new(mime)
end

# Lookup mime type by filename
Expand All @@ -82,7 +82,7 @@ def self.by_magic(io)
io = StringIO.new(io.to_s, 'rb:binary')
end
mime = MAGIC.find {|type, matches| magic_match(io, matches) }
mime ? new(mime[0]) : nil
mime && new(mime[0])
end

# Return type as string
Expand All @@ -97,7 +97,7 @@ def ==(x)

private

def child?(child, parent)
def self.child?(child, parent)
child == parent || TYPES.key?(child) && TYPES[child][1].any? {|p| child?(p, parent) }
end

Expand Down

0 comments on commit 061cadd

Please sign in to comment.