Last active
December 16, 2015 06:48
-
-
Save milligramme/5393644 to your computer and use it in GitHub Desktop.
RT数とFav数を表示する Earthquake.gem plugin
This file contains 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
# -*- coding: utf-8 -*- | |
# add fav's and rt's count | |
# ストリーミングで流れてくるときは余り意味がない | |
Earthquake.once do | |
@rt_and_fav_count ||= "" | |
end | |
Earthquake.init do | |
output_filter do |item| | |
next unless item['text'] | |
rt_count = item['retweet_count'].to_i | |
fav_count = item['favorite_count'].to_i | |
#mark for retweet and favorite | |
rt, fav = %w{^ *} | |
@rt_and_fav_count = | |
[ | |
rt_count > 0 ? "#{rt}#{rt_count}".c(33, 7) : nil, | |
fav_count > 0 ? "#{fav}#{fav_count}".c(36, 7) : nil, | |
(rt_count + fav_count) > 0 ? " " : nil | |
].compact.join | |
item['text'] = @rt_and_fav_count + item['text'] | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
:status するとだぶって表示される。