Class: BreezyPDFLite::Response
- Inherits:
-
Object
- Object
- BreezyPDFLite::Response
- Defined in:
- lib/breezy_pdf_lite/response.rb
Overview
RenderRequest -> Net::HTTPResponse wrapper that is streaming compatable
Instance Method Summary collapse
- #body ⇒ Object
- #each(&blk) ⇒ Object
- #headers ⇒ Object
-
#initialize(response) ⇒ Response
constructor
A new instance of Response.
- #status ⇒ Object
Constructor Details
#initialize(response) ⇒ Response
Returns a new instance of Response.
6 7 8 |
# File 'lib/breezy_pdf_lite/response.rb', line 6 def initialize(response) @response = response end |
Instance Method Details
#body ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/breezy_pdf_lite/response.rb', line 26 def body io = StringIO.new io.binmode each do |chunk| io.write chunk end io.flush io.rewind io end |
#each(&blk) ⇒ Object
22 23 24 |
# File 'lib/breezy_pdf_lite/response.rb', line 22 def each(&blk) @response.read_body(&blk) end |
#headers ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/breezy_pdf_lite/response.rb', line 14 def headers { "Content-Type" => "application/pdf", "Content-Length" => @response.header["Content-Length"], "Content-Disposition" => @response.header["Content-Disposition"] } end |
#status ⇒ Object
10 11 12 |
# File 'lib/breezy_pdf_lite/response.rb', line 10 def status @status ||= @response.code.to_i end |