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:
parent
8a93648cec
commit
fe2f5dc21b
2 changed files with 9 additions and 0 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue