Switch branches/tags
Find file
Fetching contributors…
Cannot retrieve contributors at this time
82 lines (51 sloc) 2.3 KB

Tweet About Gem

Takes a twitter username and returns a list of words. Can also return a Hash with the count for each word. Options to not include retweets, to set the number of tweets to be processed, and to return all words, without removing the useless ones. See Options Hash.

The words are are ordered list of the most frequently tweeted words.

  • The casing of words doesn't matter (the = The = THE). Output is downcased.
  • URLs are removed.


gem install tweetabout


gem 'tweetabout'




Takes a single string, and an optional options hash


#instantiate and call the sort_words method
@tweetwords ="jack").sort_words

#now you have two attributes #stauts and #words
@tweetwords.status = :ok
can also be: :invalid_username, :no_tweets, or :error

#default returns an array of words, sorted from most to least tweeted.
@tweetwords.words = [frisbee, golf, ...]
#instantiate, call the sort_words method, and pass :with_count => true
@tweetwords ="jack").sort_words(:with_count => true)

#will now return a Hash with counts for each word
@tweetwords.words = {"fisbee" => 5, "golf"   => 3, ...} }

##Options Hash:"@username").sort_words(:options => {})
tweets:      n      (default 200)   #the number of tweets to process
include_rts: t/f    (default true)  #include re-tweets by default
with_count:  t/f    (default false) #if true, returns a Hash in the form of {word: n}, otherwise an Array of words is returned
all_words:   t/f    (default false) #see `Junk Words`.  If set to true, no words are left out


#returns an Array of words sorted by most frequent."jack").sort_words

#returns a Hash of words with each count sorted by most frequent."jack").sort(with_count: true)

#returns an Array of words sorted by most frequent for last 1,000 tweets"jack").sort(tweets: 1000)

##Junk Words These words are removed. If you don't want them removed, pass the option :all_words => true

articles: "the", "a", "an" pronouns: "he", "him", "her", "she", "i", "you", "they", "them", "it" other_junk: "for", "from", "not", "but"