Class: LLM::File
- Inherits:
-
Object
- Object
- LLM::File
- Defined in:
- lib/llm/file.rb
Instance Attribute Summary collapse
-
#path ⇒ String
readonly
Returns the path to a file.
Class Method Summary collapse
-
.mime_types ⇒ Hash
Returns a hash of common file extensions and their corresponding MIME types.
Instance Method Summary collapse
-
#initialize(path) ⇒ File
constructor
A new instance of File.
-
#mime_type ⇒ String
Returns the MIME type of the file.
Constructor Details
#initialize(path) ⇒ File
Returns a new instance of File.
48 49 50 |
# File 'lib/llm/file.rb', line 48 def initialize(path) @path = path end |
Instance Attribute Details
#path ⇒ String (readonly)
Returns the path to a file
46 47 48 |
# File 'lib/llm/file.rb', line 46 def path @path end |
Class Method Details
.mime_types ⇒ Hash
Returns a hash of common file extensions and their corresponding MIME types
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/llm/file.rb', line 8 def self.mime_types @mime_types ||= { # Images ".png" => "image/png", ".jpg" => "image/jpeg", ".jpeg" => "image/jpeg", ".webp" => "image/webp", # Videos ".flv" => "video/x-flv", ".mov" => "video/quicktime", ".mpeg" => "video/mpeg", ".mpg" => "video/mpeg", ".mp4" => "video/mp4", ".webm" => "video/webm", ".wmv" => "video/x-ms-wmv", ".3gp" => "video/3gpp", # Audio ".aac" => "audio/aac", ".flac" => "audio/flac", ".mp3" => "audio/mpeg", ".m4a" => "audio/mp4", ".mpga" => "audio/mpeg", ".opus" => "audio/opus", ".pcm" => "audio/L16", ".wav" => "audio/wav", ".weba" => "audio/webm", # Documents ".pdf" => "application/pdf", ".txt" => "text/plain" }.freeze end |
Instance Method Details
#mime_type ⇒ String
Returns the MIME type of the file
55 56 57 |
# File 'lib/llm/file.rb', line 55 def mime_type self.class.mime_types[File.extname(path)] end |