Class: LinkThumbnailer::Processor
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- LinkThumbnailer::Processor
- Defined in:
- lib/link_thumbnailer/processor.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#http ⇒ Object
readonly
Returns the value of attribute http.
-
#redirect_count ⇒ Object
readonly
Returns the value of attribute redirect_count.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #call(url = '', redirect_count = 0, headers = {}) ⇒ Object
-
#initialize ⇒ Processor
constructor
A new instance of Processor.
- #start(url) ⇒ Object
Constructor Details
#initialize ⇒ Processor
Returns a new instance of Processor.
13 14 15 16 17 18 |
# File 'lib/link_thumbnailer/processor.rb', line 13 def initialize @config = ::LinkThumbnailer.page.config @http = ::Net::HTTP::Persistent.new super(config) end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
11 12 13 |
# File 'lib/link_thumbnailer/processor.rb', line 11 def config @config end |
#http ⇒ Object (readonly)
Returns the value of attribute http.
11 12 13 |
# File 'lib/link_thumbnailer/processor.rb', line 11 def http @http end |
#redirect_count ⇒ Object (readonly)
Returns the value of attribute redirect_count.
11 12 13 |
# File 'lib/link_thumbnailer/processor.rb', line 11 def redirect_count @redirect_count end |
#url ⇒ Object
Returns the value of attribute url.
10 11 12 |
# File 'lib/link_thumbnailer/processor.rb', line 10 def url @url end |
Instance Method Details
#call(url = '', redirect_count = 0, headers = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/link_thumbnailer/processor.rb', line 26 def call(url = '', redirect_count = 0, headers = {}) self.url = url @redirect_count = redirect_count raise ::LinkThumbnailer::RedirectLimit if too_many_redirections? with_valid_url do set_http_headers(headers) perform_request end rescue ::Net::HTTPExceptions, ::SocketError, ::Timeout::Error, ::Net::HTTP::Persistent::Error => e raise ::LinkThumbnailer::HTTPError.new(e.) end |
#start(url) ⇒ Object
20 21 22 23 24 |
# File 'lib/link_thumbnailer/processor.rb', line 20 def start(url) result = call(url) shutdown result end |