Class: RedirectFollower
- Inherits:
-
Object
- Object
- RedirectFollower
- Defined in:
- lib/redirect_follower.rb
Overview
Follow redirects for given urls with net http to find out their destinations
Source code mostly ripped from John Nunemaker: railstips.org/blog/archives/2009/03/04/following-redirects-with-nethttp/
Defined Under Namespace
Classes: TooManyRedirects
Instance Attribute Summary collapse
-
#original_url ⇒ Object
Returns the value of attribute original_url.
-
#redirect_limit ⇒ Object
Returns the value of attribute redirect_limit.
- #response ⇒ Object
- #url ⇒ Object
Instance Method Summary collapse
- #body ⇒ Object
-
#initialize(original_url, limit = 5) ⇒ RedirectFollower
constructor
A new instance of RedirectFollower.
Constructor Details
#initialize(original_url, limit = 5) ⇒ RedirectFollower
Returns a new instance of RedirectFollower.
23 24 25 |
# File 'lib/redirect_follower.rb', line 23 def initialize(original_url, limit=5) @original_url, @redirect_limit = original_url, limit end |
Instance Attribute Details
#original_url ⇒ Object
Returns the value of attribute original_url.
20 21 22 |
# File 'lib/redirect_follower.rb', line 20 def original_url @original_url end |
#redirect_limit ⇒ Object
Returns the value of attribute redirect_limit.
20 21 22 |
# File 'lib/redirect_follower.rb', line 20 def redirect_limit @redirect_limit end |
#response ⇒ Object
36 37 38 39 |
# File 'lib/redirect_follower.rb', line 36 def response resolve unless @response @response end |
#url ⇒ Object
27 28 29 30 |
# File 'lib/redirect_follower.rb', line 27 def url resolve unless @url @url end |
Instance Method Details
#body ⇒ Object
32 33 34 |
# File 'lib/redirect_follower.rb', line 32 def body response.body end |