From 845ea285bec2da1457366fcb4f83b5936bc49f64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=98=88king?= Date: Mon, 17 Sep 2012 01:20:52 -0600 Subject: Add input_array.pop! For pry-de's ,- command. --- lib/pry/history_array.rb | 5 +++++ test/test_history_array.rb | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/pry/history_array.rb b/lib/pry/history_array.rb index 04ae3f3d..48a101e6 100644 --- a/lib/pry/history_array.rb +++ b/lib/pry/history_array.rb @@ -89,6 +89,11 @@ class Pry ((@count - size)...@count).map { |n| @hash[n] } end + def pop! + @hash.delete @count - 1 + @count -= 1 + end + def inspect "#<#{self.class} size=#{size} first=#{@count - size} max_size=#{max_size}>" end diff --git a/test/test_history_array.rb b/test/test_history_array.rb index bc453c68..f1bd07aa 100644 --- a/test/test_history_array.rb +++ b/test/test_history_array.rb @@ -59,4 +59,9 @@ describe Pry::HistoryArray do 12.times { |n| @array << n } @array.entries.compact.size.should == 10 end + + it 'should pop!' do + @populated.pop! + @populated.to_a.should == [1, 2, 3] + end end -- cgit v1.2.1