module Ripl::History
Constants
- HISTORY_FILE
Public Instance Methods
after_loop()
click to toggle source
Calls superclass method
# File lib/ripl/history.rb, line 26 def after_loop() super; write_history end
before_loop()
click to toggle source
Calls superclass method
# File lib/ripl/history.rb, line 25 def before_loop() super; read_history end
get_input()
click to toggle source
Calls superclass method
# File lib/ripl/history.rb, line 10 def get_input (history << super)[-1] end
history()
click to toggle source
# File lib/ripl/history.rb, line 8 def history() @history ||= [] end
history_file()
click to toggle source
# File lib/ripl/history.rb, line 4 def history_file @history_file ||= config[:history] && File.expand_path(config[:history]) end
read_history()
click to toggle source
# File lib/ripl/history.rb, line 14 def read_history if ((history_file && File.exists?(history_file)) && history.empty?) IO.readlines(history_file).each {|e| history << e.chomp } end end
write_history()
click to toggle source
# File lib/ripl/history.rb, line 20 def write_history if history_file File.open(history_file, 'w') {|f| f.puts(*Array(history)) } end end