mirror of
https://github.com/KevinMidboe/linguist.git
synced 2025-10-29 17:50:22 +00:00
Add file?, text? and image? helpers
This commit is contained in:
@@ -33,6 +33,23 @@ module Linguist
|
||||
@mime_type ||= Mime.lookup(extname)
|
||||
end
|
||||
|
||||
def media_type
|
||||
mime_type.split('/').first
|
||||
end
|
||||
|
||||
def file?
|
||||
image? || !text? || mime_type == 'octet-stream'
|
||||
end
|
||||
|
||||
def text?
|
||||
media_type == 'text' ||
|
||||
mime_type == 'application/json'
|
||||
end
|
||||
|
||||
def image?
|
||||
['.png', '.jpg', '.jpeg', '.gif'].include?(extname)
|
||||
end
|
||||
|
||||
def to_s
|
||||
@path.dup
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user