Class: Anthropic::FilePart

Inherits:
Object
  • Object
show all
Defined in:
lib/anthropic/file_part.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(content, filename: nil, content_type: nil) ⇒ FilePart



43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/anthropic/file_part.rb', line 43

def initialize(content, filename: nil, content_type: nil)
  @content_type = content_type
  @filename =
    case [filename, (@content = content)]
    in [String | Pathname, _]
      ::File.basename(filename)
    in [nil, Pathname]
      content.basename.to_path
    in [nil, IO]
      content.to_path
    else
      filename
    end
end

Instance Attribute Details

#contentPathname, ... (readonly)



6
7
8
# File 'lib/anthropic/file_part.rb', line 6

def content
  @content
end

#content_typeString? (readonly)



9
10
11
# File 'lib/anthropic/file_part.rb', line 9

def content_type
  @content_type
end

#filenameString? (readonly)



12
13
14
# File 'lib/anthropic/file_part.rb', line 12

def filename
  @filename
end

Instance Method Details

#to_json(*a) ⇒ String



33
# File 'lib/anthropic/file_part.rb', line 33

def to_json(*a) = read.to_json(*a)

#to_yaml(*a) ⇒ String



38
# File 'lib/anthropic/file_part.rb', line 38

def to_yaml(*a) = read.to_yaml(*a)