Class: ImageInfo::RequestHandler
- Inherits:
-
Object
- Object
- ImageInfo::RequestHandler
- Defined in:
- lib/image_info/request_handler.rb
Instance Attribute Summary collapse
-
#buffer ⇒ Object
readonly
Returns the value of attribute buffer.
-
#image ⇒ Object
readonly
Returns the value of attribute image.
Instance Method Summary collapse
- #build ⇒ Object
-
#initialize(image) ⇒ RequestHandler
constructor
A new instance of RequestHandler.
Constructor Details
#initialize(image) ⇒ RequestHandler
Returns a new instance of RequestHandler.
7 8 9 10 |
# File 'lib/image_info/request_handler.rb', line 7 def initialize(image) @image = image @buffer = StringIO.new end |
Instance Attribute Details
#buffer ⇒ Object (readonly)
Returns the value of attribute buffer.
5 6 7 |
# File 'lib/image_info/request_handler.rb', line 5 def buffer @buffer end |
#image ⇒ Object (readonly)
Returns the value of attribute image.
5 6 7 |
# File 'lib/image_info/request_handler.rb', line 5 def image @image end |
Instance Method Details
#build ⇒ Object
12 13 14 15 16 17 18 19 20 |
# File 'lib/image_info/request_handler.rb', line 12 def build ::Typhoeus::Request.new(image.uri.to_s, followlocation: true, accept_encoding: :gzip).tap do |request| request.on_body do |chunk| buffer.write(chunk) buffer.rewind :abort if max_image_size_reached? || found_image_info? end end end |