Last active
December 30, 2015 17:49
-
-
Save davekaro/7863843 to your computer and use it in GitHub Desktop.
Marginally better version of https://github.com/JamesChevalier/hashtagged/blob/master/app.rb#L17-L27
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
timeline = client.user_timeline(@user_name, { count: 200, include_entities: true }) | |
hashtag_list = timeline.map { |tweet| tweet.hashtags.collect(&:text) } | |
@hashtags = hashtag_list.uniq.map do |tag| | |
{ text: tag, | |
weight: hashtag_list.grep(tag).size, | |
link: { href: "https://twitter.com/search?q=%23#{tag}", target: '_blank', title: "#{tag}" } } | |
end | |
@hashtags = @hashtags.to_json |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Oh and https://github.com/JamesChevalier/hashtagged/blob/master/app.rb#L18 should be
hashtag_list = timeline.flat_map { |tweet| tweet.hashtags.map(&:text) }
instead ofhashtag_list = timeline.map { |tweet| tweet.hashtags.map(&:text) }.flatten