Skip to content

Commit

Permalink
Enumerate MIME::Type objects instead of assoc arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
ameuret committed Apr 15, 2013
1 parent fd53425 commit 644259d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions lib/mime/types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -597,12 +597,13 @@ def defined_types #:nodoc:
@type_variants.values.flatten
end

# Returns the number of known types. A shortcut of MIME::Types[//].size
def count
@type_variants.size
defined_types.size
end

def each
@type_variants.each { |t| yield t }
defined_types.each { |t| yield t }
end

@__types__ = self.new(VERSION)
Expand Down
2 changes: 1 addition & 1 deletion test/test_mime_types.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_class_of
end

def test_class_enumerable
assert( MIME::Types.any? {|types| types[0] == 'text/plain'} )
assert( MIME::Types.any? {|type| type.content_type == 'text/plain'} )
end

def test_class_count
Expand Down

0 comments on commit 644259d

Please sign in to comment.