Permalink
Browse files

text? helper improved

  • Loading branch information...
1 parent 13b726a commit bbe2490f44a2b5d4046041f027bbd822addcd8a2 @minad committed Jan 23, 2011
Showing with 2 additions and 8 deletions.
  1. +1 −8 lib/mimemagic.rb
  2. +1 −0 test/mimemagic_test.rb
View
@@ -41,14 +41,7 @@ def self.remove(type)
end
# Returns true if type is a text format
- def text?
- child_of? 'text/plain'
- end
-
- # Returns true if type is image
- def image?
- mediatype == 'image'
- end
+ def text?; mediatype == 'text' || child_of?('text/plain'); end
# Mediatype shortcuts
def image?; mediatype == 'image'; end
View
@@ -11,6 +11,7 @@
it 'should have mediatype helpers' do
MimeMagic.new('text/plain').should.be.text
MimeMagic.new('text/html').should.be.text
+ MimeMagic.new('application/xhtml+xml').should.be.text
MimeMagic.new('application/octet-stream').should.not.be.text
MimeMagic.new('image/png').should.not.be.text
MimeMagic.new('image/png').should.be.image

0 comments on commit bbe2490

Please sign in to comment.