Class: ClaudeMemory::Index::QueryOptions

Inherits:
Object
  • Object
show all
Defined in:
lib/claude_memory/index/query_options.rb

Constant Summary collapse

SCOPE_ALL =
:all
SCOPE_PROJECT =
:project
SCOPE_GLOBAL =
:global
DEFAULT_LIMIT =
20
DEFAULT_SCOPE =
SCOPE_ALL

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(query_text:, limit: DEFAULT_LIMIT, scope: DEFAULT_SCOPE, source: nil) ⇒ QueryOptions

Returns a new instance of QueryOptions.



15
16
17
18
19
20
21
# File 'lib/claude_memory/index/query_options.rb', line 15

def initialize(query_text:, limit: DEFAULT_LIMIT, scope: DEFAULT_SCOPE, source: nil)
  @query_text = query_text
  @limit = limit
  @scope = scope.to_sym
  @source = source&.to_sym
  freeze
end

Instance Attribute Details

#limitObject (readonly)

Returns the value of attribute limit.



13
14
15
# File 'lib/claude_memory/index/query_options.rb', line 13

def limit
  @limit
end

#query_textObject (readonly)

Returns the value of attribute query_text.



13
14
15
# File 'lib/claude_memory/index/query_options.rb', line 13

def query_text
  @query_text
end

#scopeObject (readonly)

Returns the value of attribute scope.



13
14
15
# File 'lib/claude_memory/index/query_options.rb', line 13

def scope
  @scope
end

#sourceObject (readonly)

Returns the value of attribute source.



13
14
15
# File 'lib/claude_memory/index/query_options.rb', line 13

def source
  @source
end

Instance Method Details

#==(other) ⇒ Object



50
51
52
53
54
55
56
# File 'lib/claude_memory/index/query_options.rb', line 50

def ==(other)
  other.is_a?(QueryOptions) &&
    other.query_text == query_text &&
    other.limit == limit &&
    other.scope == scope &&
    other.source == source
end

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/claude_memory/index/query_options.rb', line 58

def eql?(other)
  self == other
end

#for_globalObject



32
33
34
35
36
37
38
39
# File 'lib/claude_memory/index/query_options.rb', line 32

def for_global
  self.class.new(
    query_text: query_text,
    limit: limit,
    scope: scope,
    source: :global
  )
end

#for_projectObject



23
24
25
26
27
28
29
30
# File 'lib/claude_memory/index/query_options.rb', line 23

def for_project
  self.class.new(
    query_text: query_text,
    limit: limit,
    scope: scope,
    source: :project
  )
end

#hashObject



62
63
64
# File 'lib/claude_memory/index/query_options.rb', line 62

def hash
  [query_text, limit, scope, source].hash
end

#with_limit(new_limit) ⇒ Object



41
42
43
44
45
46
47
48
# File 'lib/claude_memory/index/query_options.rb', line 41

def with_limit(new_limit)
  self.class.new(
    query_text: query_text,
    limit: new_limit,
    scope: scope,
    source: source
  )
end