diff app/models/tweet.rb @ 15:207917e41964

Add tweets~ Feature is now on par with the thing it's replacing.
author edogawaconan <me@myconan.net>
date Fri, 05 Sep 2014 20:37:25 +0900
parents
children 6e3ff830e94a
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/app/models/tweet.rb	Fri Sep 05 20:37:25 2014 +0900
@@ -0,0 +1,21 @@
+class Tweet
+  CONFIG = {
+    :consumer_key => ENV["RT_CONSUMER_KEY"],
+    :consumer_secret => ENV["RT_CONSUMER_SECRET"],
+    :access_token => ENV["RT_OAUTH_TOKEN"],
+    :access_token_secret => ENV["RT_OAUTH_TOKEN_SECRET"]
+  }
+
+  def timeline
+    @timeline ||= @client.user_timeline(@twitter_id)
+  end
+
+  def initialize(twitter_id)
+    @client = Twitter::REST::Client.new do |config|
+                CONFIG.each do |cfg_key, cfg_value|
+                  config.public_send("#{cfg_key}=", cfg_value)
+                end
+              end
+    @twitter_id = twitter_id
+  end
+end