Class: Eye::Utils::Tail

Inherits:
Array show all
Defined in:
lib/eye/utils/tail.rb

Direct Known Subclasses

Process::StatesHistory

Instance Method Summary collapse

Methods inherited from Array

#extract_options!

Constructor Details

#initialize(max_size = 100) ⇒ Tail

limited array



5
6
7
8
# File 'lib/eye/utils/tail.rb', line 5

def initialize(max_size = 100)
  @max_size = max_size
  super()
end

Instance Method Details

#<<(el) ⇒ Object



16
17
18
# File 'lib/eye/utils/tail.rb', line 16

def <<(el)
  push(el)
end

#push(el) ⇒ Object



10
11
12
13
14
# File 'lib/eye/utils/tail.rb', line 10

def push(el)
  super(el)
  shift if length > @max_size
  self
end