Class: Ripl::ReadlineShell

Inherits:
Shell
  • Object
show all
Includes:
Completion
Defined in:
lib/ripl/readline_shell.rb

Constant Summary

Constants inherited from Shell

Shell::OPTIONS

Instance Attribute Summary

Attributes inherited from Shell

#binding, #line, #result_prompt

Instance Method Summary collapse

Methods included from Completion

#start_completion

Methods inherited from Shell

#format_error, #format_result, #initialize, #loop, #loop_once, #print_eval_error

Constructor Details

This class inherits a constructor from Ripl::Shell

Instance Method Details

#after_loopObject



22
23
24
# File 'lib/ripl/readline_shell.rb', line 22

def after_loop
  File.open(history_file, 'w') {|f| f.write Readline::HISTORY.to_a.join("\n") }
end

#before_loopObject



15
16
17
18
19
20
# File 'lib/ripl/readline_shell.rb', line 15

def before_loop
  start_completion
  super
  File.exists?(history_file) &&
    IO.readlines(history_file).each {|e| Readline::HISTORY << e.chomp }
end

#get_inputObject



7
8
9
# File 'lib/ripl/readline_shell.rb', line 7

def get_input
  Readline.readline @options[:prompt], true
end

#history_fileObject



11
12
13
# File 'lib/ripl/readline_shell.rb', line 11

def history_file
  @history_file ||= File.expand_path(@options[:history])
end