Class: MadChatter::MessageHistory
- Inherits:
-
Object
- Object
- MadChatter::MessageHistory
- Defined in:
- lib/mad_chatter/message_history.rb
Instance Method Summary collapse
- #add(message) ⇒ Object
- #all ⇒ Object
- #clear ⇒ Object
-
#initialize ⇒ MessageHistory
constructor
A new instance of MessageHistory.
Constructor Details
#initialize ⇒ MessageHistory
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() @stack << @stack = @stack.pop(10) if @stack.length > 10 end |
#all ⇒ Object
13 14 15 |
# File 'lib/mad_chatter/message_history.rb', line 13 def all @stack end |
#clear ⇒ Object
17 18 19 |
# File 'lib/mad_chatter/message_history.rb', line 17 def clear @stack = [] end |