Method: TTY::Reader::History#initialize

Defined in:
lib/tty/reader/history.rb

#initialize(max_size = DEFAULT_SIZE, duplicates: true, cycle: false, exclude: DEFAULT_EXCLUDE) {|_self| ... } ⇒ History

Create a History buffer

Parameters:

  • max_size (Integer) (defaults to: DEFAULT_SIZE)

    the maximum size for history buffer

  • cycle (Boolean) (defaults to: false)

    whether or not the history should cycle, false by default

  • duplicates (Boolean) (defaults to: true)

    whether or not to store duplicates, true by default

  • exclude (Boolean) (defaults to: DEFAULT_EXCLUDE)

    a Proc to exclude items from storing in history

Yields:

  • (_self)

Yield Parameters:



66
67
68
69
70
71
72
73
74
75
76
# File 'lib/tty/reader/history.rb', line 66

def initialize(max_size = DEFAULT_SIZE, duplicates: true, cycle: false,
               exclude: DEFAULT_EXCLUDE)
  @max_size   = max_size
  @index      = nil
  @history    = []
  @duplicates = duplicates
  @exclude    = exclude
  @cycle      = cycle

  yield self if block_given?
end