summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author☈king <rking@sharpsaw.org>2012-09-17 01:20:52 -0600
committerrking@sharpsaw.org <>2012-09-17 01:20:52 -0600
commit845ea285bec2da1457366fcb4f83b5936bc49f64 (patch)
treeb7f6b690bedb20f5baa296428d9c83aa64055afa
parent0b5b06d90651f45f29b65ca57b12d2520d9fff9d (diff)
downloadpry-845ea285bec2da1457366fcb4f83b5936bc49f64.tar.gz
Add input_array.pop!
For pry-de's ,- command.
-rw-r--r--lib/pry/history_array.rb5
-rw-r--r--test/test_history_array.rb5
2 files changed, 10 insertions, 0 deletions
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