Class: Byebug::History
- Inherits:
-
Object
- Object
- Byebug::History
- Defined in:
- lib/byebug/history.rb
Class Method Summary collapse
Class Method Details
.load ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'lib/byebug/history.rb', line 6 def load open(Setting[:histfile], 'r') do |file| file.each do |line| line.chomp! Readline::HISTORY << line end end if File.exist?(Setting[:histfile]) end |
.save ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/byebug/history.rb', line 15 def save open(Setting[:histfile], 'w') do |file| Readline::HISTORY.to_a.last(Setting[:histsize]).each do |line| file.puts line unless line.strip.empty? end end end |
.to_s(size = Setting[:histsize]) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/byebug/history.rb', line 23 def to_s(size = Setting[:histsize]) n_entries = Readline::HISTORY.length < size ? Readline::HISTORY.length : size first = Readline::HISTORY.length - n_entries commands = Readline::HISTORY.to_a.last(n_entries) s = '' commands.each_with_index do |command, index| s += ("%5d %s\n" % [first + index + 1, command]) end return s end |