# class Reline::History

### Public Class Methods

new (config)
Source

    # File lib/reline/history.rb, line 2
    def initialize(config)
      @config = config
    end

### Public Instance Methods

<< (val)
Source

    # File lib/reline/history.rb, line 52
    def <<(val)
      # If history_size is zero, all histories are dropped.
      return self if @config.history_size.zero?
      # If history_size is negative, history size is unlimited.
      if @config.history_size.positive?
        shift if size + 1 > @config.history_size
      end
      super(Reline::Unicode.safe_encode(val, Reline.encoding_system_needs))
    end

Calls superclass method `Array#<<`
[] (index)
Source

    # File lib/reline/history.rb, line 15
    def [](index)
      index = check_index(index) unless index.is_a?(Range)
      super(index)
    end

Calls superclass method `Array::[]`
[]= (index, val)
Source

    # File lib/reline/history.rb, line 20
    def []=(index, val)
      index = check_index(index)
      super(index, Reline::Unicode.safe_encode(val, Reline.encoding_system_needs))
    end

Calls superclass method `Array#[]=`
concat (*val)
Source

    # File lib/reline/history.rb, line 25
    def concat(*val)
      val.each do |v|
        push(*v)
      end
    end

delete_at (index)
Source

    # File lib/reline/history.rb, line 10
    def delete_at(index)
      index = check_index(index)
      super(index)
    end

Calls superclass method `Array#delete_at`
push (*val)
Source

    # File lib/reline/history.rb, line 31
    def push(*val)
      # If history_size is zero, all histories are dropped.
      return self if @config.history_size.zero?
      # If history_size is negative, history size is unlimited.
      if @config.history_size.positive?
        diff = size + val.size - @config.history_size
        if diff > 0
          if diff <= size
            shift(diff)
          else
            diff -= size
            clear
            val.shift(diff)
          end
        end
      end
      super(*(val.map{ |v|
        Reline::Unicode.safe_encode(v, Reline.encoding_system_needs)
      }))
    end

Calls superclass method `Array#push`
to_s ()
Source

    # File lib/reline/history.rb, line 6
    def to_s
      'HISTORY'
    end

### Private Instance Methods

check_index (index)
Source

    # File lib/reline/history.rb, line 62
            def check_index(index)
      index += size if index < 0
      if index < -2147483648 or 2147483647 < index
        raise RangeError.new("integer #{index} too big to convert to 'int'")
      end
      # If history_size is negative, history size is unlimited.
      if @config.history_size.positive?
        if index < -@config.history_size or @config.history_size < index
          raise RangeError.new("index=<#{index}>")
        end
      end
      raise IndexError.new("index=<#{index}>") if index < 0 or size <= index
      index
    end