1
0
Fork 0
mirror of https://github.com/pry/pry.git synced 2022-11-09 12:35:05 -05:00

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