Class: OllamaAgent::RubyIndex::Index
- Inherits:
-
Object
- Object
- OllamaAgent::RubyIndex::Index
- Defined in:
- lib/ollama_agent/ruby_index/index.rb
Overview
Immutable snapshot of class/module and method definitions for a tree.
Instance Attribute Summary collapse
-
#constants ⇒ Object
readonly
Returns the value of attribute constants.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
-
#files_indexed ⇒ Object
readonly
Returns the value of attribute files_indexed.
-
#methods ⇒ Object
readonly
Returns the value of attribute methods.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Instance Method Summary collapse
-
#initialize(root:, constants:, methods:, errors:, files_indexed:) ⇒ Index
constructor
A new instance of Index.
- #search_class(pattern) ⇒ Object
- #search_class_or_module(pattern) ⇒ Object
- #search_method(pattern) ⇒ Object
- #search_module(pattern) ⇒ Object
- #summary_line ⇒ Object
Constructor Details
#initialize(root:, constants:, methods:, errors:, files_indexed:) ⇒ Index
Returns a new instance of Index.
9 10 11 12 13 14 15 |
# File 'lib/ollama_agent/ruby_index/index.rb', line 9 def initialize(root:, constants:, methods:, errors:, files_indexed:) @root = root @constants = constants.freeze @methods = methods.freeze @errors = errors.freeze @files_indexed = files_indexed end |
Instance Attribute Details
#constants ⇒ Object (readonly)
Returns the value of attribute constants.
7 8 9 |
# File 'lib/ollama_agent/ruby_index/index.rb', line 7 def constants @constants end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
7 8 9 |
# File 'lib/ollama_agent/ruby_index/index.rb', line 7 def errors @errors end |
#files_indexed ⇒ Object (readonly)
Returns the value of attribute files_indexed.
7 8 9 |
# File 'lib/ollama_agent/ruby_index/index.rb', line 7 def files_indexed @files_indexed end |
#methods ⇒ Object (readonly)
Returns the value of attribute methods.
7 8 9 |
# File 'lib/ollama_agent/ruby_index/index.rb', line 7 def methods @methods end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
7 8 9 |
# File 'lib/ollama_agent/ruby_index/index.rb', line 7 def root @root end |
Instance Method Details
#search_class(pattern) ⇒ Object
17 18 19 |
# File 'lib/ollama_agent/ruby_index/index.rb', line 17 def search_class(pattern) match_records(@constants.select { |r| r[:kind] == :class }, pattern) end |
#search_class_or_module(pattern) ⇒ Object
25 26 27 |
# File 'lib/ollama_agent/ruby_index/index.rb', line 25 def search_class_or_module(pattern) match_records(@constants, pattern) end |
#search_method(pattern) ⇒ Object
29 30 31 |
# File 'lib/ollama_agent/ruby_index/index.rb', line 29 def search_method(pattern) match_records(@methods, pattern, field: :name) end |
#search_module(pattern) ⇒ Object
21 22 23 |
# File 'lib/ollama_agent/ruby_index/index.rb', line 21 def search_module(pattern) match_records(@constants.select { |r| r[:kind] == :module }, pattern) end |
#summary_line ⇒ Object
33 34 35 36 |
# File 'lib/ollama_agent/ruby_index/index.rb', line 33 def summary_line "ruby_index: #{@files_indexed} files, #{@constants.size} classes/modules, #{@methods.size} methods" \ "#{", #{@errors.size} parse warning(s)" unless errors.empty?}" end |