Class: AIRefactor::Context
- Inherits:
-
Object
- Object
- AIRefactor::Context
- Defined in:
- lib/ai_refactor/context.rb
Instance Method Summary collapse
-
#initialize(files:, text:, logger:) ⇒ Context
constructor
A new instance of Context.
- #prepare_context ⇒ Object
Constructor Details
#initialize(files:, text:, logger:) ⇒ Context
Returns a new instance of Context.
5 6 7 8 9 |
# File 'lib/ai_refactor/context.rb', line 5 def initialize(files:, text:, logger:) @files = files @text = text @logger = logger end |
Instance Method Details
#prepare_context ⇒ Object
11 12 13 14 15 16 17 18 19 |
# File 'lib/ai_refactor/context.rb', line 11 def prepare_context context = read_contexts&.compact file_context = (context && context.size.positive?) ? "Here is some related files:\n\n#{context.join("\n")}" : "" if @text.nil? || @text.empty? file_context else "\n#{file_context}\n\n#{@text}\n" end end |