Class: Spectacular::History

Inherits:
Object
  • Object
show all
Defined in:
lib/spectacular/history.rb

Instance Method Summary collapse

Constructor Details

#initialize(size = 10) ⇒ History

Returns a new instance of History.



5
6
7
8
9
# File 'lib/spectacular/history.rb', line 5

def initialize size = 10
  @groups = Hash.new { |h,k|
    h[k] = new_list size
  }
end

Instance Method Details

#[](k) ⇒ Object



23
24
25
# File 'lib/spectacular/history.rb', line 23

def [] k
  @groups[k].to_a
end

#add(k, v) ⇒ Object



11
12
13
# File 'lib/spectacular/history.rb', line 11

def add k, v
  @groups[k] << v
end

#last(k, len = nil) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/spectacular/history.rb', line 15

def last k, len = nil
  if len
    @groups[k].last len
  else
    @groups[k].last
  end
end