Class: LLM::Spell::CLI
- Inherits:
-
Object
- Object
- LLM::Spell::CLI
- Defined in:
- lib/llm/spell/cli.rb
Instance Attribute Summary collapse
-
#content ⇒ Object
readonly
Returns the value of attribute content.
-
#text ⇒ Object
readonly
Returns the value of attribute text.
Instance Method Summary collapse
-
#initialize(text) ⇒ CLI
constructor
A new instance of CLI.
- #start ⇒ Object
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
#content ⇒ Object (readonly)
Returns the value of attribute content.
5 6 7 |
# File 'lib/llm/spell/cli.rb', line 5 def content @content end |
#text ⇒ Object (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
#start ⇒ Object
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 |