Class: TwitterSearch::Tweets

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/tweets.rb

Constant Summary collapse

VARS =
[:since_id, :max_id, :results_per_page, :page, :query, :next_page]

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Tweets

Returns a new instance of Tweets.



19
20
21
22
# File 'lib/tweets.rb', line 19

def initialize(opts)
  @results = opts['results'].collect { |each| Tweet.new(each) }
  VARS.each { |each| instance_variable_set "@#{each}", opts[each.to_s] }
end

Instance Method Details

#[](index) ⇒ Object



32
33
34
# File 'lib/tweets.rb', line 32

def [](index)
  @results[index]
end

#each(&block) ⇒ Object



24
25
26
# File 'lib/tweets.rb', line 24

def each(&block)
  @results.each(&block)
end

#get_next_pageObject



40
41
42
43
# File 'lib/tweets.rb', line 40

def get_next_page
  client = Client.new
  return client.query( CGI.parse( @next_page[1..-1] ) )
end

#has_next_page?Boolean

Returns:

  • (Boolean)


36
37
38
# File 'lib/tweets.rb', line 36

def has_next_page?
  ! @next_page.nil?
end

#sizeObject



28
29
30
# File 'lib/tweets.rb', line 28

def size
  @results.size
end