Class: Clitwitter::Twitter
- Inherits:
-
Object
- Object
- Clitwitter::Twitter
- Defined in:
- lib/clitwitter/twit.rb
Instance Attribute Summary collapse
-
#message ⇒ Object
Returns the value of attribute message.
Instance Method Summary collapse
- #close_friends ⇒ Object
- #friends_timeline(query = {}) ⇒ Object
-
#initialize ⇒ Twitter
constructor
A new instance of Twitter.
- #post(message) ⇒ Object
Constructor Details
#initialize ⇒ Twitter
Returns a new instance of Twitter.
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/clitwitter/twit.rb', line 10 def initialize @tw = Pit.get("twitter.com") if ENV.include?('HTTP_PROXY') host,port= ENV['HTTP_PROXY'].sub(/^http:\/\//,"").split /:/ ::Twitter::HTTPAuth.http_proxy( host, port) end end |
Instance Attribute Details
#message ⇒ Object
Returns the value of attribute message.
8 9 10 |
# File 'lib/clitwitter/twit.rb', line 8 def @message end |
Instance Method Details
#close_friends ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/clitwitter/twit.rb', line 59 def close_friends if @tw["close_friends"] @tw["close_friends"] else {} end end |
#friends_timeline(query = {}) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/clitwitter/twit.rb', line 37 def friends_timeline(query={}) query[:since_id] = @last_id if @last_id begin result = @twitter.friends_timeline(query).reverse rescue ::Twitter::Unavailable warn "Twitter Service Unavailable #{Time.now}" result = [] rescue ::Timeout::Error warn "Twitter Timeout #{Time.now}" result = [] rescue ::Twitter::Unauthorized reenterAuth retry end @last_id = result.last.id unless result.empty? result end |
#post(message) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/clitwitter/twit.rb', line 21 def post begin @twitter.update() rescue ::Twitter::Unavailable warn "Twitter Service Unavailable #{Time.now}" retry rescue ::Timeout::Error warn "Twitter Timeout #{Time.now}" retry rescue ::Twitter::Unauthorized reenterAuth retry end end |