Class: LLMed::UserContexts

Inherits:
Object
  • Object
show all
Defined in:
lib/llmed/context.rb

Instance Method Summary collapse

Constructor Details

#initialize(contexts) ⇒ UserContexts

Returns a new instance of UserContexts.



8
9
10
# File 'lib/llmed/context.rb', line 8

def initialize(contexts)
  @contexts = contexts.dup
end

Instance Method Details

#[](idx) ⇒ Object



20
21
22
# File 'lib/llmed/context.rb', line 20

def [](idx)
  @contexts[idx]
end

#by_digest(digest) ⇒ Object



39
40
41
# File 'lib/llmed/context.rb', line 39

def by_digest(digest)
  @contexts.find { |ctx| ctx.same_digest?(digest) }
end

#by_name(name) ⇒ Object



35
36
37
# File 'lib/llmed/context.rb', line 35

def by_name(name)
  @contexts.find { |ctx| ctx.name == name }
end

#countObject



31
32
33
# File 'lib/llmed/context.rb', line 31

def count
  @contexts.count
end

#each(&block) ⇒ Object



12
13
14
# File 'lib/llmed/context.rb', line 12

def each(&block)
  @contexts.each(&block)
end

#each_with_next(&block) ⇒ Object



24
25
26
27
28
29
# File 'lib/llmed/context.rb', line 24

def each_with_next(&block)
  @contexts.each_with_index do |ctx, idx|
    next_ctx = @contexts[idx + 1]
    block.call(ctx, next_ctx)
  end
end

#empty?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/llmed/context.rb', line 16

def empty?
  @contexts.empty?
end