Class: LLM::Spell::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/llm/spell/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text) ⇒ CLI



7
8
9
# File 'lib/llm/spell/cli.rb', line 7

def initialize(text)
  @text = text
end

Instance Attribute Details

#contentObject (readonly)

Returns the value of attribute content.



5
6
7
# File 'lib/llm/spell/cli.rb', line 5

def content
  @content
end

#textObject (readonly)

Returns the value of attribute text.



5
6
7
# File 'lib/llm/spell/cli.rb', line 5

def text
  @text
end

Instance Method Details

#startObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/llm/spell/cli.rb', line 11

def start
  say "please wait"
  if text.mistakes.empty?
    say "no mistakes found"
  else
    text.mistakes.each.with_index do |mistake, i|
      correction = text.corrections[i]
      print "#{mistake} => #{correction}", "\n"
      print "Replace? (y/N): "
      res = $stdin.gets
      @text.to_s.gsub!(mistake, correction) if res&.strip&.downcase == "y"
      print "\n"
    end
  end
  @text
end