Class: Ollama::Image

Inherits:
Object
  • Object
show all
Defined in:
lib/ollama/image.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Image

Returns a new instance of Image.



4
5
6
# File 'lib/ollama/image.rb', line 4

def initialize(data)
  @data = data
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



10
11
12
# File 'lib/ollama/image.rb', line 10

def data
  @data
end

#pathObject

Returns the value of attribute path.



8
9
10
# File 'lib/ollama/image.rb', line 8

def path
  @path
end

Class Method Details

.for_base64(data, path: nil) ⇒ Object



13
14
15
16
17
# File 'lib/ollama/image.rb', line 13

def for_base64(data, path: nil)
  obj = new(data)
  obj.path = path
  obj
end

.for_filename(path) ⇒ Object



28
29
30
# File 'lib/ollama/image.rb', line 28

def for_filename(path)
  File.open(path, 'rb') { |io| for_io(io, path:) }
end

.for_io(io, path: nil) ⇒ Object



23
24
25
26
# File 'lib/ollama/image.rb', line 23

def for_io(io, path: nil)
  path ||= io.path
  for_string(io.read, path:)
end

.for_string(string, path: nil) ⇒ Object



19
20
21
# File 'lib/ollama/image.rb', line 19

def for_string(string, path: nil)
  for_base64(Base64.encode64(string), path:)
end

Instance Method Details

#==(other) ⇒ Object



35
36
37
# File 'lib/ollama/image.rb', line 35

def ==(other)
  @data == other.data
end

#to_sObject



39
40
41
# File 'lib/ollama/image.rb', line 39

def to_s
  @data
end