diff options
author | Marie <ml.kochsiek@fu-berlin.de> | 2016-09-14 16:38:51 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-09-14 16:38:51 +0000 |
commit | d72c87cb94213c9a507596f2103773969d1cbd30 (patch) | |
tree | 7b13646448e64e560101493eeac1a03c3a25dbd8 /app/helpers | |
parent | 42459748e9e8e30a9cc0c64eaf4b8e10814d2dc2 (diff) | |
parent | 22478d315af3590d2a344eb1aa8cf2aec0730506 (diff) |
Merge pull request #14 from LoadToCode/develop
Taking it all from branch develop and push it to branch temp_1_marie
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/twitter_helper.rb | 35 |
1 files changed, 12 insertions, 23 deletions
diff --git a/app/helpers/twitter_helper.rb b/app/helpers/twitter_helper.rb index a5e7ae4..f824a03 100644 --- a/app/helpers/twitter_helper.rb +++ b/app/helpers/twitter_helper.rb @@ -19,7 +19,13 @@ module TwitterHelper $twitter_user_info ||= [] end - def twitter_name + def update_twitter_info + twitter_user_info[0] = Time.now + twitter_user_info[1] = twitter_client.user(twitter_handle).name + twitter_user_info[2] = twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(3) + end + + def cached_info if twitter_user_info[0] == nil update_twitter_info else @@ -27,31 +33,14 @@ module TwitterHelper update_twitter_info end end - twitter_user_info[1] + twitter_user_info end - def update_twitter_info - twitter_user_info[0] = Time.now - twitter_user_info[1] = twitter_client.user(twitter_handle).name - end - - def twitter_tweets - $twitter_tweets ||= [] - end - - def twitter_timeline - if twitter_tweets[0] == nil - update_twitter_timeline - else - if Time.now > twitter_tweets[0] + 15.minutes - update_twitter_timeline - end - end - twitter_tweets[1] + def twitter_name + cached_info[1] end - def update_twitter_timeline - twitter_tweets[0] = Time.now - twitter_tweets[1] = twitter_client.user_timeline(twitter_handle).select{ |tweet| tweet.text.start_with?('RT','@')==false}.take(3) + def tweets + cached_info[2] end end |