Class: Twroute::Requester::DelayedRequest
- Inherits:
-
Struct
- Object
- Struct
- Twroute::Requester::DelayedRequest
- Defined in:
- lib/twroute/requester/delayed.rb
Instance Attribute Summary collapse
-
#post_args ⇒ Object
Returns the value of attribute post_args.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
- #do_response(response) ⇒ Object
- #is_twitter_response?(response) ⇒ Boolean
- #perform ⇒ Object
- #tweet_it(tweet) ⇒ Object
Instance Attribute Details
#post_args ⇒ Object
Returns the value of attribute post_args
12 13 14 |
# File 'lib/twroute/requester/delayed.rb', line 12 def post_args @post_args end |
#uri ⇒ Object
Returns the value of attribute uri
12 13 14 |
# File 'lib/twroute/requester/delayed.rb', line 12 def uri @uri end |
Instance Method Details
#do_response(response) ⇒ Object
19 20 21 22 23 |
# File 'lib/twroute/requester/delayed.rb', line 19 def do_response(response) if(is_twitter_response?(response)) tweet_it(response.body) end end |
#is_twitter_response?(response) ⇒ Boolean
31 32 33 |
# File 'lib/twroute/requester/delayed.rb', line 31 def is_twitter_response?(response) !!(response && response.is_a?(Net::HTTPOK) && response.header['content-type'].match( /text\/twitter/ )) end |
#perform ⇒ Object
13 14 15 16 17 |
# File 'lib/twroute/requester/delayed.rb', line 13 def perform response = Net::HTTP.post_form(uri, post_args) do_response(response) response end |
#tweet_it(tweet) ⇒ Object
25 26 27 28 29 |
# File 'lib/twroute/requester/delayed.rb', line 25 def tweet_it( tweet ) if tweet ::Twroute::Application.twitter_client.statuses.update! :status => tweet[0,139] end end |