Class: Ollama::Image
- Inherits:
-
Object
- Object
- Ollama::Image
- Defined in:
- lib/ollama/image.rb
Instance Attribute Summary collapse
-
#path ⇒ Object
Returns the value of attribute path.
Class Method Summary collapse
- .for_base64(data, path: nil) ⇒ Object
- .for_filename(path) ⇒ Object
- .for_io(io, path: nil) ⇒ Object
- .for_string(string, path: nil) ⇒ Object
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(data) ⇒ Image
constructor
A new instance of Image.
- #to_s ⇒ Object
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
#path ⇒ Object
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
11 12 13 14 15 |
# File 'lib/ollama/image.rb', line 11 def for_base64(data, path: nil) obj = new(data) obj.path = path obj end |
.for_filename(path) ⇒ Object
26 27 28 |
# File 'lib/ollama/image.rb', line 26 def for_filename(path) File.open(path, 'rb') { |io| for_io(io, path:) } end |
.for_io(io, path: nil) ⇒ Object
21 22 23 24 |
# File 'lib/ollama/image.rb', line 21 def for_io(io, path: nil) path ||= io.path for_string(io.read, path:) end |
.for_string(string, path: nil) ⇒ Object
17 18 19 |
# File 'lib/ollama/image.rb', line 17 def for_string(string, path: nil) for_base64(Base64.encode64(string), path:) end |
Instance Method Details
#==(other) ⇒ Object
33 34 35 |
# File 'lib/ollama/image.rb', line 33 def ==(other) @data == other..data end |
#to_s ⇒ Object
37 38 39 |
# File 'lib/ollama/image.rb', line 37 def to_s @data end |