Class: IRB::History
Do not use. This class is for internal use only.
Relationships & Source Files | |
Inherits: | Object |
Defined in: | lib/irb/ext/history.rb |
Class Method Summary
- .new(size = 16) ⇒ History constructor
Instance Method Summary
Constructor Details
.new(size = 16) ⇒ History
Instance Method Details
#[](idx)
[ GitHub ]# File 'lib/irb/ext/history.rb', line 75
def [](idx) begin if idx >= 0 @contents.find{|no, val| no == idx}[1] else @contents[idx][1] end rescue NameError nil end end
#inspect
[ GitHub ]# File 'lib/irb/ext/history.rb', line 94
def inspect if @contents.empty? return real_inspect end unless (last = @contents.pop)[1].equal?(self) @contents.push last last = nil end str = @contents.collect{|no, val| if val.equal?(self) "#{no} ...self-history..." else "#{no} #{val.inspect}" end }.join("\n") if str == "" str = "Empty." end @contents.push last if last str end
#push(no, val)
[ GitHub ]# File 'lib/irb/ext/history.rb', line 87
def push(no, val) @contents.push [no, val] @contents.shift if @size != 0 && @contents.size > @size end
#real_inspect
[ GitHub ]# File 'lib/irb/ext/history.rb', line 92
alias real_inspect inspect
#size(size)
[ GitHub ]# File 'lib/irb/ext/history.rb', line 68
def size(size) if size != 0 && size < @size @contents = @contents[@size - size .. @size] end @size = size end