Module: Processors::Twitter
- Includes:
- LogAware
- Defined in:
- lib/processors/twitter.rb
Overview
utilities for dealing with twitter
Class Method Summary collapse
-
.extract_links(tweet) ⇒ Object
extract the links from a given tweet.
-
.lazy_search(config) ⇒ Object
lazy update - search for a term or refresh the search if a response is available already.
- .log ⇒ Object
-
.retweet?(message) ⇒ Boolean
checks if the message is a retweet.
-
.search(config) ⇒ Object
fire a new search.
Methods included from LogAware
Class Method Details
.extract_links(tweet) ⇒ Object
extract the links from a given tweet
18 19 20 21 22 23 |
# File 'lib/processors/twitter.rb', line 18 def self.extract_links(tweet) if tweet text = tweet['text'] text.gsub(/https?:\/\/[\S]+/).to_a if text end end |
.lazy_search(config) ⇒ Object
lazy update - search for a term or refresh the search if a response is available already
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/processors/twitter.rb', line 32 def self.lazy_search(config) response = nil if config search_url = "#{config[:api_endpoint_twitter]}?since_id=#{config[:since_id]}&ors=#{config[:search_term]}&result_type=#{config[:result_type]}&rpp=#{config[:results_per_page]}" log.info "lazy search using '#{search_url}'" response = Processors::Http::http_get_json search_url else log.error "#{self}.lazy_search: no config given!" end response end |
.log ⇒ Object
8 9 10 |
# File 'lib/processors/twitter.rb', line 8 def self.log LogAware.log #TODO why doesn't the include make the log method accessible? end |
.retweet?(message) ⇒ Boolean
checks if the message is a retweet
13 14 15 |
# File 'lib/processors/twitter.rb', line 13 def self.retweet?() .index('RT @') || .index(%{"@}) || .index("\u201c@") #detect retweets end |
.search(config) ⇒ Object
fire a new search
26 27 28 29 |
# File 'lib/processors/twitter.rb', line 26 def self.search(config) search_call = "#{config[:api_endpoint_twitter]}?ors=#{config[:search_term]}&result_type=#{config[:result_type]}&rpp=#{config[:results_per_page]}" Processors::Http::http_get_json search_call end |