Class: PrettyIRB::AutoCorrector

Inherits:
Object
  • Object
show all
Defined in:
lib/pretty_irb/auto_corrector.rb

Class Method Summary collapse

Class Method Details

.auto_correct_code(code) ⇒ Object

Auto-correct common typos in code



21
22
23
24
25
26
# File 'lib/pretty_irb/auto_corrector.rb', line 21

def auto_correct_code(code)
  code = fix_method_names(code)
  code
rescue
  code
end

.suggest_corrections(error) ⇒ Object

Suggest corrections for common Ruby mistakes



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/pretty_irb/auto_corrector.rb', line 5

def suggest_corrections(error)
  case error
  when NameError
    suggest_name_error(error)
  when NoMethodError
    suggest_method_error(error)
  when SyntaxError
    suggest_syntax_error(error)
  else
    ""
  end
rescue
  ""
end