module Rib::SqueezeHistory

Public Instance Methods

loop_once() click to toggle source

squeeze history in memory too

Calls superclass method
# File lib/rib/core/squeeze_history.rb, line 11
def loop_once
  return super if SqueezeHistory.disabled?
  begin
    input, last_input = history[-1], history[-2]
  rescue IndexError # EditLine is really broken, to_a is needed for it
    array = history.to_a
    input, last_input = array[-1], array[-2]
  end
  history.pop if input.to_s.strip == '' ||
                (history.size > 1 && input == last_input)
  super
end
write_history() click to toggle source

write squeezed history

Calls superclass method
# File lib/rib/core/squeeze_history.rb, line 27
def write_history
  return super if SqueezeHistory.disabled?
  config[:history] = squeezed_history
  super
end

Private Instance Methods

squeezed_history() click to toggle source
# File lib/rib/core/squeeze_history.rb, line 36
def squeezed_history
  history.to_a.inject([]){ |result, item|
    if result.last == item || item.strip == ''
      result
    else
      result << item
    end
  }
end