| Module | IRB::HistorySavingAbility |
| In: |
lib/irb/ext/save-history.rb
|
# File lib/irb/ext/save-history.rb, line 53
53: def HistorySavingAbility.create_finalizer
54: proc do
55: if num = IRB.conf[:SAVE_HISTORY] and (num = num.to_i) > 0
56: if hf = IRB.conf[:HISTORY_FILE]
57: file = File.expand_path(hf)
58: end
59: file = IRB.rc_file("_history") unless file
60: open(file, 'w' ) do |f|
61: hist = HISTORY.to_a
62: f.puts(hist[-num..-1] || hist)
63: end
64: end
65: end
66: end
# File lib/irb/ext/save-history.rb, line 68
68: def HistorySavingAbility.extended(obj)
69: ObjectSpace.define_finalizer(obj, HistorySavingAbility.create_finalizer)
70: obj.load_history
71: obj
72: end