Class: MadChatter::MessageHistory

Inherits:
Object
  • Object
show all
Defined in:
lib/mad_chatter/message_history.rb

Instance Method Summary collapse

Constructor Details

#initializeMessageHistory

Returns a new instance of MessageHistory.



4
5
6
# File 'lib/mad_chatter/message_history.rb', line 4

def initialize
   @stack = []
end

Instance Method Details

#add(message) ⇒ Object



8
9
10
11
# File 'lib/mad_chatter/message_history.rb', line 8

def add(message)
  @stack << message
  @stack = @stack.pop(10) if @stack.length > 10
end

#allObject



13
14
15
# File 'lib/mad_chatter/message_history.rb', line 13

def all
  @stack
end

#clearObject



17
18
19
# File 'lib/mad_chatter/message_history.rb', line 17

def clear
  @stack = []
end