Skip to content

Instantly share code, notes, and snippets.

@milligramme
Last active December 16, 2015 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save milligramme/5393644 to your computer and use it in GitHub Desktop.
Save milligramme/5393644 to your computer and use it in GitHub Desktop.
RT数とFav数を表示する Earthquake.gem plugin
# -*- 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
@milligramme
Copy link
Author

:status するとだぶって表示される。
img

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment