Module IRB::HistorySavingAbility
In: lib/irb/ext/save-history.rb

Methods

Included Modules

Readline

Public Class methods

[Source]

    # 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

[Source]

    # 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

Public Instance methods

[Source]

    # File lib/irb/ext/save-history.rb, line 74
74:     def load_history
75:       hist = IRB.conf[:HISTORY_FILE]
76:       hist = IRB.rc_file("_history") unless hist
77:       if File.exist?(hist)
78:         open(hist) do |f|
79:           f.each {|l| HISTORY << l.chomp}
80:         end
81:       end
82:     end

[Validate]