Class: God::Timeline

Inherits:
Array
  • Object
show all
Defined in:
lib/god/timeline.rb

Instance Method Summary collapse

Constructor Details

#initialize(max_size) ⇒ Timeline

Instantiate a new Timeline

+max_size+ is the maximum size to which the timeline should grow

Returns Timeline


8
9
10
11
# File 'lib/god/timeline.rb', line 8

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

Instance Method Details

#push(val) ⇒ Object Also known as: <<

Push a value onto the Timeline

+val+ is the value to push

Returns Timeline


17
18
19
20
# File 'lib/god/timeline.rb', line 17

def push(val)
  self.concat([val])
  shift if size > @max_size
end