Class: Twat::TweetStack

Inherits:
Object
  • Object
show all
Defined in:
lib/twat/tweetstack.rb

Instance Method Summary collapse

Constructor Details

#initializeTweetStack

A circularly linked list representing all of the tweets printed thus far, for the purposes of retrieving them after being printed



5
6
7
8
# File 'lib/twat/tweetstack.rb', line 5

def initialize
  @stack = {}
  @_next = 0
end

Instance Method Details

#<<(v) ⇒ Object



14
15
16
# File 'lib/twat/tweetstack.rb', line 14

def << v
  @stack[nxt] = v
end

#[](k) ⇒ Object



10
11
12
# File 'lib/twat/tweetstack.rb', line 10

def [] k
  @stack[k]
end

#include?(k) ⇒ Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/twat/tweetstack.rb', line 18

def include? k
  @stack.keys.include?(k)
end

#lastObject



22
23
24
25
# File 'lib/twat/tweetstack.rb', line 22

def last
  # I see the irony
  @_next
end