Sha256: 13758a7f757acdf22b0473891c1dcfdb175df3ee962e57c2e14c213b2842259a
Contents?: true
Size: 656 Bytes
Versions: 2
Compression:
Stored size: 656 Bytes
Contents
# frozen_string_literal: true module BreezyPDFLite # Request conversion of a HTML string to PDF class RenderRequest def initialize(body) @body = body end def submit client.post("/render/html", @body) end def to_file raise BreezyPDFLiteError, "#{response.code}: #{response.body}" if response.code != "201" @to_file ||= Tempfile.new(%w[response .pdf]).tap do |file| file.binmode file.write response.body file.flush file.rewind end end private def response @response ||= submit end def client @client ||= Client.new end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
breezy_pdf_lite-0.0.4 | lib/breezy_pdf_lite/render_request.rb |
breezy_pdf_lite-0.0.3 | lib/breezy_pdf_lite/render_request.rb |