Skip to content

Instantly share code, notes, and snippets.

@etagwerker
Created January 5, 2010 04:13
Show Gist options
  • Save etagwerker/269144 to your computer and use it in GitHub Desktop.
Save etagwerker/269144 to your computer and use it in GitHub Desktop.
module Topsy
..
# Returns list of authors that talk about the query. The list is sorted by frequency of posts and the influence of authors.
#
# @param [String] q the search query string
# @param [Hash] options method options
# @option options [String] :window Time window for results. (default: 'a') Options: auto - automatically pick the most recent and relevant window. h last hour, d last day, w last week, m last month, a all time
# @option options [Integer] :page page number of the result set. (default: 1, max: 10)
# @option options [Integer] :perpage limit number of results per page. (default: 10, max: 50)
# @return [Topsy::Page]
def self.author_search(q, options={})
result = Topsy::Client.new.author_search(q, options)
Topsy::Page.new(result, Topsy::Author)
end
..
end
PLUS
module Topsy
class Page
def initialize(content, klass)
@klass = klass
super(content)
end
def list=(value)
result = []
if value
value.each{ |x| result << @klass.new(x) }
self[:list] = result
else
self[:list] = value
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment