module Rib::History
Public Instance Methods
after_loop()
click to toggle source
Calls superclass method
# File lib/rib/core/history.rb, line 21 def after_loop return super if History.disabled? write_history Rib.say("History wrote to: #{history_file_path}") if $VERBOSE super end
before_loop()
click to toggle source
get_input()
click to toggle source
Calls superclass method
# File lib/rib/core/history.rb, line 28 def get_input return super if History.disabled? (history << super).last end
history()
click to toggle source
The history data
# File lib/rib/core/history.rb, line 36 def history; config[:history] ||= []; end
read_history()
click to toggle source
Read config into history
, handled in history_file
plugin
Calls superclass method
# File lib/rib/core/history.rb, line 39 def read_history return super if History.disabled? File.exist?(history_file_path) && history.empty? && File.readlines(history_file_path).each{ |e| history << e.chomp } end
write_history()
click to toggle source
Write history
into config, handled in history_file
plugin
Calls superclass method
# File lib/rib/core/history.rb, line 46 def write_history return super if History.disabled? history_text = "#{history.to_a.last(history_size).join("\n")}\n" File.write(history_file_path, history_text) end
Private Instance Methods
history_file()
click to toggle source
# File lib/rib/core/history.rb, line 55 def history_file config[:history_file] ||= File.join(Rib.home, 'history.rb') end
history_file_path()
click to toggle source
# File lib/rib/core/history.rb, line 59 def history_file_path config[:history_file_path] ||= File.expand_path(history_file) end
history_size()
click to toggle source
# File lib/rib/core/history.rb, line 63 def history_size config[:history_size] ||= 500 end