Class Pry::HistoryArray
In: lib/pry/history_array.rb
Parent: Object

A history array is an array to which you can only add elements. Older entries are removed progressively, so that the aray never contains more than N elements.

History arrays are used by Pry to store the output of the last commands.

@example

  ary = Pry::HistoryArray.new 10
  ary << 1 << 2 << 3
  ary[0] # => 1
  ary[1] # => 2
  10.times { |n| ary << n }
  ary[0] # => nil
  ary[-1] # => 9

Methods

<<   []   count   each   empty?   inspect   length   new   size   to_a  

Included Modules

Enumerable

Attributes

max_size  [R]  @return [Integer] Maximum amount of objects in the array

Public Class methods

@param [Integer] size Maximum amount of objects in the array

Public Instance methods

Pushes an object at the end of the array @param [Object] value Object to be added

@overload [](index)

  @param [Integer] index Index of the item to access.
  @return [Object, nil] Item at that index or nil if it has been removed.

@overload [](index, size)

  @param [Integer] index Index of the first item to access.
  @param [Integer] size Amount of items to access
  @return [Array, nil] The selected items. Nil if index is greater than
    the size of the array.

@overload [](range)

  @param [Range<Integer>] range Range of indices to access.
  @return [Array, nil] The selected items. Nil if index is greater than
    the size of the array.
count()

Alias for size

length()

Alias for size

@return [Integer] Amount of objects in the array

[Validate]