Module: Ripl::Johnson::MultiLine
- Defined in:
- lib/ripl/johnson/multi_line.rb
Instance Method Summary collapse
- #before_loop ⇒ Object
- #handle_interrupt ⇒ Object
- #loop_eval(input) ⇒ Object
- #loop_once ⇒ Object
- #print_eval_error(e) ⇒ Object
- #prompt ⇒ Object
Instance Method Details
#before_loop ⇒ Object
2 3 4 5 |
# File 'lib/ripl/johnson/multi_line.rb', line 2 def before_loop super @buffer = @unterminated_string = nil end |
#handle_interrupt ⇒ Object
38 39 40 41 |
# File 'lib/ripl/johnson/multi_line.rb', line 38 def handle_interrupt @buffer = @unterminated_string = nil super end |
#loop_eval(input) ⇒ Object
29 30 31 32 33 34 35 36 |
# File 'lib/ripl/johnson/multi_line.rb', line 29 def loop_eval(input) if @buffer join = @unterminated_string ? "" : "\n" super @buffer* join + join + input else super input end end |
#loop_once ⇒ Object
11 12 13 14 15 16 |
# File 'lib/ripl/johnson/multi_line.rb', line 11 def loop_once catch(:multiline) do super @buffer = nil end end |
#print_eval_error(e) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/ripl/johnson/multi_line.rb', line 18 def print_eval_error(e) if e.is_a?(::Johnson::Error) && e.original_exception.to_s[/^SyntaxError/] @unterminated_string = e.to_s[/unterminated string literal/] @buffer ||= [] @buffer << @input throw :multiline else super end end |
#prompt ⇒ Object
7 8 9 |
# File 'lib/ripl/johnson/multi_line.rb', line 7 def prompt @buffer ? config[:johnson_multi_line_prompt] : super end |