Module: Scrapbooker::Services

Includes:
TweetMethods
Defined in:
lib/scrapbooker/services/services.rb,
lib/scrapbooker/services/twitter_feed.rb

Defined Under Namespace

Modules: TweetMethods Classes: TwitterFeed

Instance Method Summary collapse

Methods included from TweetMethods

#hashtags, #is_retweet, #links, #media, #mentions, #original_tweet

Instance Method Details

#poll_twitterObject



37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/scrapbooker/services/twitter_feed.rb', line 37

def poll_twitter
  results = Twitter.user_timeline(self.twitter_feed.username, {
    :include_rts              => self.twitter_feed.include_retweets, 
    :include_replies          => self.twitter_feed.exclude_replies,
    :include_entities         => self.twitter_feed.include_entities,
    :count                    => self.twitter_feed.count,
    :trim_user                => self.twitter_feed.trim_user
  })
  for tweet in results do
    store_tweet(tweet)
  end
end

#poll_twitter?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/scrapbooker/services/twitter_feed.rb', line 33

def poll_twitter?
  poll_twitter if self.twitter_feed.active
end

#store_tweet(tweet) ⇒ Object



50
51
52
53
54
55
56
57
58
# File 'lib/scrapbooker/services/twitter_feed.rb', line 50

def store_tweet(tweet)
  self.create( 
    :source                   => 'twitter', 
    :source_id                => tweet.id, 
    :raw_feed                 => tweet.instance_variable_get('@attrs').to_yaml,
    :posted_at                => tweet.created_at,
    :entry                    => tweet.text
  )
end

#twitter_feedObject



6
7
8
# File 'lib/scrapbooker/services/services.rb', line 6

def twitter_feed
  @twitter_feed ||= TwitterFeed.new(self.configuration.twitter_feed)
end