Class: Otter::Connection
- Inherits:
-
Object
- Object
- Otter::Connection
- Defined in:
- lib/otter/connection.rb
Instance Method Summary collapse
- #authorinfo(username, &block) ⇒ Object
- #authorsearch(query, window = 'a', page = nil, perpage = nil, &block) ⇒ Object
-
#initialize(identifier) ⇒ Connection
constructor
A new instance of Connection.
- #linkpostcount(url, contains = nil, &block) ⇒ Object
- #linkposts(url, contains = nil, page = nil, perpage = nil, &block) ⇒ Object
- #profilesearch(query, page = nil, perpage = nil, &block) ⇒ Object
- #related(url, page = nil, perpage = nil, &block) ⇒ Object
- #search(query, window = 'a', page = nil, perpage = nil, &block) ⇒ Object
- #searchcount(query, &block) ⇒ Object
- #stats(url, contains = nil, &block) ⇒ Object
- #tags(url, page = nil, perpage = nil, &block) ⇒ Object
- #trackbacks(url, contains = nil, infonly = nil, page = nil, perpage = nil, &block) ⇒ Object
- #trending(page = nil, perpage = nil, &block) ⇒ Object
- #urlinfo(url, &block) ⇒ Object
Constructor Details
#initialize(identifier) ⇒ Connection
Returns a new instance of Connection.
4 5 6 |
# File 'lib/otter/connection.rb', line 4 def initialize(identifier) @identifier = identifier end |
Instance Method Details
#authorinfo(username, &block) ⇒ Object
8 9 10 |
# File 'lib/otter/connection.rb', line 8 def (username, &block) self.request('authorinfo', {:url => "http://twitter.com/#{username}"}, Author, block) end |
#authorsearch(query, window = 'a', page = nil, perpage = nil, &block) ⇒ Object
12 13 14 |
# File 'lib/otter/connection.rb', line 12 def (query, window = 'a', page = nil, perpage = nil, &block) self.request('authorsearch', {:q => query, :window => window}, Author, block, page, perpage) end |
#linkpostcount(url, contains = nil, &block) ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/otter/connection.rb', line 20 def linkpostcount(url, contains = nil, &block) self.request('linkpostcount', {:url => url, :contains => contains}, Base, lambda { |response, base| if response.is_a?(Error) block.call response else block.call response, Integer(base.data['contains']), Integer(base.data['all']) end }) end |
#linkposts(url, contains = nil, page = nil, perpage = nil, &block) ⇒ Object
16 17 18 |
# File 'lib/otter/connection.rb', line 16 def linkposts(url, contains = nil, page = nil, perpage = nil, &block) self.request('linkposts', {:url => url, :contains => contains}, Post, block, page, perpage) end |
#profilesearch(query, page = nil, perpage = nil, &block) ⇒ Object
30 31 32 |
# File 'lib/otter/connection.rb', line 30 def profilesearch(query, page = nil, perpage = nil, &block) self.request('profilesearch', {:q => query}, Author, block, page, perpage) end |
#related(url, page = nil, perpage = nil, &block) ⇒ Object
34 35 36 |
# File 'lib/otter/connection.rb', line 34 def (url, page = nil, perpage = nil, &block) self.request('related', {:url => url}, Link, block, page, perpage) end |
#search(query, window = 'a', page = nil, perpage = nil, &block) ⇒ Object
38 39 40 |
# File 'lib/otter/connection.rb', line 38 def search(query, window = 'a', page = nil, perpage = nil, &block) self.request('search', {:q => query, :window => window}, Link, block, page, perpage) end |
#searchcount(query, &block) ⇒ Object
42 43 44 |
# File 'lib/otter/connection.rb', line 42 def searchcount(query, &block) self.request('searchcount', {:q => query}, Count, block) end |
#stats(url, contains = nil, &block) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/otter/connection.rb', line 46 def stats(url, contains = nil, &block) self.request('stats', {:url => url, :contains => contains}, Base, lambda { |response, base| if response.is_a?(Error) block.call response else block.call( response, base.data['topsy_trackback_url'], Integer(base.data['contains']), Integer(base.data['influential']), Integer(base.data['all'])) end }) end |
#tags(url, page = nil, perpage = nil, &block) ⇒ Object
60 61 62 |
# File 'lib/otter/connection.rb', line 60 def (url, page = nil, perpage = nil, &block) self.request('tags', {:url => url}, Tag, block, page, perpage) end |
#trackbacks(url, contains = nil, infonly = nil, page = nil, perpage = nil, &block) ⇒ Object
64 65 66 |
# File 'lib/otter/connection.rb', line 64 def trackbacks(url, contains = nil, infonly = nil, page = nil, perpage = nil, &block) self.request('trackbacks', {:url => url, :contains => contains, :infonly => infonly}, Trackback, block, page, perpage) end |
#trending(page = nil, perpage = nil, &block) ⇒ Object
68 69 70 |
# File 'lib/otter/connection.rb', line 68 def trending(page = nil, perpage = nil, &block) self.request('trending', nil, Topic, block, page, perpage) end |
#urlinfo(url, &block) ⇒ Object
72 73 74 |
# File 'lib/otter/connection.rb', line 72 def urlinfo(url, &block) self.request('urlinfo', {:url => url}, UrlInfo, block) end |