Class: Twitter::SearchResults

Inherits:
Base
  • Object
show all
Defined in:
lib/twitter/search_results.rb

Instance Method Summary (collapse)

Methods inherited from Base

#[], #attr_equal, attr_reader, #attrs, #attrs_equal, fetch, fetch_or_new, from_response, identity_map, #initialize, store, #update

Constructor Details

This class inherits a constructor from Twitter::Base

Instance Method Details

- (Float) completed_in

Returns:

  • (Float)


16
17
18
# File 'lib/twitter/search_results.rb', line 16

def completed_in
  @attrs[:search_metadata][:completed_in] if search_metadata?
end

- (Integer) max_id

Returns:

  • (Integer)


21
22
23
# File 'lib/twitter/search_results.rb', line 21

def max_id
  @attrs[:search_metadata][:max_id] if search_metadata?
end

- (Hash) next_results Also known as: next_page

Note:

Returned Hash can be merged into the previous search options list to easily access the next page.

Returns a Hash of query parameters for the next result in the search

Returns:

  • (Hash)

    The parameters needed to fetch the next page.



60
61
62
63
64
65
# File 'lib/twitter/search_results.rb', line 60

def next_results
  if next_results?
    query_string = strip_first_character(@attrs[:search_metadata][:next_results])
    query_string_to_hash(query_string)
  end
end

- (Boolean) next_results? Also known as: next_page?

Returns:

  • (Boolean)


51
52
53
# File 'lib/twitter/search_results.rb', line 51

def next_results?
  !@attrs[:search_metadata][:next_results].nil? if search_metadata?
end

- (Integer) page

Returns:

  • (Integer)


26
27
28
# File 'lib/twitter/search_results.rb', line 26

def page
  @attrs[:search_metadata][:page] if search_metadata?
end

- (String) query

Returns:

  • (String)


31
32
33
# File 'lib/twitter/search_results.rb', line 31

def query
  @attrs[:search_metadata][:query] if search_metadata?
end

- (Hash) refresh_url Also known as: refresh_page

Note:

Returned Hash can be merged into the previous search options list to easily access the refresh page.

Returns a Hash of query parameters for the refresh URL in the search

Returns:

  • (Hash)

    The parameters needed to refresh the page.



72
73
74
75
# File 'lib/twitter/search_results.rb', line 72

def refresh_url
  query_string = strip_first_character(@attrs[:search_metadata][:refresh_url])
  query_string_to_hash(query_string)
end

- (Integer) results_per_page Also known as: rpp

Returns:

  • (Integer)


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

def results_per_page
  @attrs[:search_metadata][:results_per_page] if search_metadata?
end

- (Boolean) search_metadata?

Returns:

  • (Boolean)


41
42
43
# File 'lib/twitter/search_results.rb', line 41

def search_metadata?
  !@attrs[:search_metadata].nil?
end

- (Integer) since_id

Returns:

  • (Integer)


46
47
48
# File 'lib/twitter/search_results.rb', line 46

def since_id
  @attrs[:search_metadata][:since_id] if search_metadata?
end

- (Array<Twitter::Tweet>) statuses Also known as: collection, results

Returns:



7
8
9
10
11
# File 'lib/twitter/search_results.rb', line 7

def statuses
  @results ||= Array(@attrs[:statuses]).map do |tweet|
    Twitter::Tweet.fetch_or_new(tweet)
  end
end