module RubyLLM::MimeType
MimeTypes module provides methods to handle MIME types using Marcel gem
Constants
- DOCUMENT_MIME_PREFIXES
- DOCUMENT_MIME_TYPES
- NON_TEXT_PREFIX_TEXT_MIME_TYPES
-
MIME types that donβt have a text/ prefix but should be treated as text
- TEXT_SUFFIXES
-
MIME types that have a text/ prefix but need to be handled differently
Public Instance Methods
Source
# File lib/ruby_llm/mime_type.rb, line 22 def audio?(type) type.start_with?('audio/') end
Source
# File lib/ruby_llm/mime_type.rb, line 30 def document?(type) return false if pdf?(type) || text?(type) DOCUMENT_MIME_TYPES.include?(type) || DOCUMENT_MIME_PREFIXES.any? { |prefix| type.start_with?(prefix) } end
Source
# File lib/ruby_llm/mime_type.rb, line 10 def for(...) Marcel::MimeType.for(...) end
Source
# File lib/ruby_llm/mime_type.rb, line 14 def image?(type) type.start_with?('image/') end
Source
# File lib/ruby_llm/mime_type.rb, line 26 def pdf?(type) type == 'application/pdf' end
Source
# File lib/ruby_llm/mime_type.rb, line 37 def text?(type) type.start_with?('text/') || TEXT_SUFFIXES.any? { |suffix| type.end_with?(suffix) } || NON_TEXT_PREFIX_TEXT_MIME_TYPES.include?(type) end
Source
# File lib/ruby_llm/mime_type.rb, line 18 def video?(type) type.start_with?('video/') end