Class: Ollama::Utils::Tags
- Inherits:
-
Object
- Object
- Ollama::Utils::Tags
- Includes:
- Enumerable
- Defined in:
- lib/ollama/utils/tags.rb
Defined Under Namespace
Classes: Tag
Instance Method Summary collapse
- #add(tag, source: nil) ⇒ Object
- #clear ⇒ Object
- #each(&block) ⇒ Object
- #empty? ⇒ Boolean
-
#initialize(tags = [], source: nil) ⇒ Tags
constructor
A new instance of Tags.
- #size ⇒ Object
- #to_s(link: true) ⇒ Object
Constructor Details
#initialize(tags = [], source: nil) ⇒ Tags
Returns a new instance of Tags.
28 29 30 31 |
# File 'lib/ollama/utils/tags.rb', line 28 def initialize( = [], source: nil) @set = [] .each { |tag| add(tag, source:) } end |
Instance Method Details
#add(tag, source: nil) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ollama/utils/tags.rb', line 33 def add(tag, source: nil) unless tag.is_a?(Tag) tag = Tag.new(tag, source:) end index = @set.bsearch_index { _1 >= tag } if index == nil @set.push(tag) elsif @set.at(index) != tag @set.insert(index, tag) end self end |
#clear ⇒ Object
54 55 56 |
# File 'lib/ollama/utils/tags.rb', line 54 def clear @set.clear end |
#each(&block) ⇒ Object
58 59 60 |
# File 'lib/ollama/utils/tags.rb', line 58 def each(&block) @set.each(&block) end |
#empty? ⇒ Boolean
46 47 48 |
# File 'lib/ollama/utils/tags.rb', line 46 def empty? @set.empty? end |
#size ⇒ Object
50 51 52 |
# File 'lib/ollama/utils/tags.rb', line 50 def size @set.size end |
#to_s(link: true) ⇒ Object
63 64 65 |
# File 'lib/ollama/utils/tags.rb', line 63 def to_s(link: true) @set.map { |tag| tag.to_s(link:) } * ' ' end |