Class: OpenAI::FilePart
- Inherits:
-
Object
- Object
- OpenAI::FilePart
- Defined in:
- lib/openai/file_part.rb
Instance Attribute Summary collapse
- #content ⇒ Pathname, ... readonly
- #content_type ⇒ String? readonly
- #filename ⇒ String? readonly
Instance Method Summary collapse
-
#initialize(content, filename: nil, content_type: nil) ⇒ FilePart
constructor
A new instance of FilePart.
- #to_json(*a) ⇒ String
- #to_yaml(*a) ⇒ String
Constructor Details
#initialize(content, filename: nil, content_type: nil) ⇒ FilePart
Returns a new instance of FilePart.
43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/openai/file_part.rb', line 43 def initialize(content, filename: nil, content_type: nil) @content = content @filename = case content in Pathname filename.nil? ? content.basename.to_path : ::File.basename(filename) else filename.nil? ? nil : ::File.basename(filename) end @content_type = content_type end |
Instance Attribute Details
#content ⇒ Pathname, ... (readonly)
6 7 8 |
# File 'lib/openai/file_part.rb', line 6 def content @content end |
#content_type ⇒ String? (readonly)
9 10 11 |
# File 'lib/openai/file_part.rb', line 9 def content_type @content_type end |
#filename ⇒ String? (readonly)
12 13 14 |
# File 'lib/openai/file_part.rb', line 12 def filename @filename end |
Instance Method Details
#to_json(*a) ⇒ String
33 |
# File 'lib/openai/file_part.rb', line 33 def to_json(*a) = read.to_json(*a) |
#to_yaml(*a) ⇒ String
38 |
# File 'lib/openai/file_part.rb', line 38 def to_yaml(*a) = read.to_yaml(*a) |