Class: PDFService::WebApp

Inherits:
Sinatra::Base
  • Object
show all
Defined in:
lib/pdf_service/web_app.rb

Constant Summary collapse

VALID_SCHEMES =
%w(http https).freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(pdf_service:) ⇒ WebApp

Returns a new instance of WebApp.



7
8
9
10
# File 'lib/pdf_service/web_app.rb', line 7

def initialize(pdf_service:)
  super()
  @pdf_service = pdf_service
end

Instance Attribute Details

#pdf_serviceObject (readonly)

Returns the value of attribute pdf_service.



12
13
14
# File 'lib/pdf_service/web_app.rb', line 12

def pdf_service
  @pdf_service
end

Instance Method Details

#ErrorResponse(message, status: 500) ⇒ Object



41
42
43
# File 'lib/pdf_service/web_app.rb', line 41

def ErrorResponse(message, status: 500)
  [status, {'Content-Type' => 'text/plain'}, [message]]
end

#PDFResponse(pdf_data, status: 200) ⇒ Object



45
46
47
# File 'lib/pdf_service/web_app.rb', line 45

def PDFResponse(pdf_data, status: 200)
  [status, {'Content-Type' => 'application/pdf'}, [pdf_data]]
end