adds HistoryArray#to_h and spec

This commit is contained in:
Russell Jennings 2013-12-07 07:09:42 -05:00
parent 8a93648cec
commit fe2f5dc21b
2 changed files with 9 additions and 0 deletions

View File

@ -89,6 +89,11 @@ class Pry
((@count - size)...@count).map { |n| @hash[n] }
end
# Returns [Hash] copy of the internal @hash history
def to_h
Marshal.load( Marshal.dump(@hash) )
end
def pop!
@hash.delete @count - 1
@count -= 1

View File

@ -64,4 +64,8 @@ describe Pry::HistoryArray do
@populated.pop!
@populated.to_a.should == [1, 2, 3]
end
it 'should return an indexed hash' do
@populated.to_h[0].should == @populated[0]
end
end