Class: Wirble::History

Inherits:
Object
  • Object
show all
Defined in:
lib/wirble.rb

Overview

Basic IRB history support. This is based on the tips from wiki.rubygarden.org/Ruby/page/show/Irb/TipsAndTricks

Constant Summary collapse

DEFAULTS =
{
  :history_path   => ENV['IRB_HISTORY_FILE'] || "~/.irb_history",
  :history_size   => (ENV['IRB_HISTORY_SIZE'] || 1000).to_i,
  :history_perms  => File::WRONLY | File::CREAT | File::TRUNC,
}

Instance Method Summary collapse

Constructor Details

#initialize(opt = nil) ⇒ History

Returns a new instance of History.



115
116
117
118
119
120
# File 'lib/wirble.rb', line 115

def initialize(opt = nil)
  @opt = DEFAULTS.merge(opt || {})
  return unless defined? Readline::HISTORY
  load_history
  Kernel.at_exit { save_history }
end