Module: Ripl::History

Included in:
Shell
Defined in:
lib/ripl/history.rb

Instance Method Summary collapse

Instance Method Details

#after_loopObject



21
# File 'lib/ripl/history.rb', line 21

def after_loop() write_history end

#before_loopObject



12
13
14
15
16
# File 'lib/ripl/history.rb', line 12

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

#get_inputObject



8
9
10
# File 'lib/ripl/history.rb', line 8

def get_input
  (@history << super)[-1]
end

#historyObject



6
# File 'lib/ripl/history.rb', line 6

def history() @history ||= [] end

#history_fileObject



2
3
4
# File 'lib/ripl/history.rb', line 2

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

#write_historyObject



18
19
20
# File 'lib/ripl/history.rb', line 18

def write_history
  File.open(history_file, 'w') {|f| f.write Array(history).join("\n") }
end