Class: BreezyPDFLite::Response

Inherits:
Object
  • Object
show all
Defined in:
lib/breezy_pdf_lite/response.rb

Overview

RenderRequest -> Net::HTTPResponse wrapper that is streaming compatable

Instance Method Summary collapse

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

#bodyObject



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

#headersObject



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

#statusObject



10
11
12
# File 'lib/breezy_pdf_lite/response.rb', line 10

def status
  @status ||= @response.code.to_i
end