Server IP : 195.201.23.43 / Your IP : 3.149.248.173 Web Server : Apache System : Linux webserver2.vercom.be 5.4.0-192-generic #212-Ubuntu SMP Fri Jul 5 09:47:39 UTC 2024 x86_64 User : kdecoratie ( 1041) PHP Version : 7.1.33-63+ubuntu20.04.1+deb.sury.org+1 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /lib/ruby/2.7.0/reline/ |
Upload File : |
class Reline::History < Array def initialize(config) @config = config end def to_s 'HISTORY' end def delete_at(index) index = check_index(index) super(index) end def [](index) index = check_index(index) unless index.is_a?(Range) super(index) end def []=(index, val) index = check_index(index) super(index, String.new(val, encoding: Encoding::default_external)) end def concat(*val) val.each do |v| push(*v) end end def push(*val) diff = size + val.size - @config.history_size if diff > 0 if diff <= size shift(diff) else diff -= size clear val.shift(diff) end end super(*(val.map{ |v| String.new(v, encoding: Encoding::default_external) })) end def <<(val) shift if size + 1 > @config.history_size super(String.new(val, encoding: Encoding::default_external)) end private def check_index(index) index += size if index < 0 raise RangeError.new("index=<#{index}>") if index < -@config.history_size or @config.history_size < index raise IndexError.new("index=<#{index}>") if index < 0 or size <= index index end endPrivate