Class: BenefitsIntakeService::Utilities::ConvertToPdf
- Inherits:
-
Object
- Object
- BenefitsIntakeService::Utilities::ConvertToPdf
- Defined in:
- lib/benefits_intake_service/utilities/convert_to_pdf.rb
Constant Summary collapse
- CAN_CONVERT =
%w[.jpg .jpeg .png .gif .bmp .txt].freeze
- IMG_TYPES =
%w[.jpg .jpeg .png .gif .bmp].freeze
- NON_IMG_TYPES =
CAN_CONVERT - IMG_TYPES
- NOTE_PAGE =
'This PDF has been generated/converted by va.gov from a non-PDF document supplied by the end-user. This cover page has been auto-generated. The user\'s content begins on page #2.'
Instance Attribute Summary collapse
-
#converted_file ⇒ Object
Returns the value of attribute converted_file.
-
#converted_filename ⇒ Object
Returns the value of attribute converted_filename.
-
#entropy ⇒ Object
readonly
Returns the value of attribute entropy.
-
#original_file ⇒ Object
Returns the value of attribute original_file.
-
#original_filename ⇒ Object
Returns the value of attribute original_filename.
Instance Method Summary collapse
-
#initialize(file) ⇒ ConvertToPdf
constructor
A new instance of ConvertToPdf.
Constructor Details
#initialize(file) ⇒ ConvertToPdf
Returns a new instance of ConvertToPdf.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/benefits_intake_service/utilities/convert_to_pdf.rb', line 19 def initialize(file) @original_file = file @original_filename = File.basename(@original_file) @entropy = "#{Common::FileHelpers.random_file_path}.#{Time.now.to_i}" @converted_filename = "#{@entropy}.converted_from_#{@original_filename}.pdf" extension = File.extname(@original_filename).downcase case extension when *IMG_TYPES convert_img! when *NON_IMG_TYPES convert_txt! else raise "Unsupported file type (#{extension}), cannot convert to PDF." end end |
Instance Attribute Details
#converted_file ⇒ Object
Returns the value of attribute converted_file.
16 17 18 |
# File 'lib/benefits_intake_service/utilities/convert_to_pdf.rb', line 16 def converted_file @converted_file end |
#converted_filename ⇒ Object
Returns the value of attribute converted_filename.
16 17 18 |
# File 'lib/benefits_intake_service/utilities/convert_to_pdf.rb', line 16 def converted_filename @converted_filename end |
#entropy ⇒ Object (readonly)
Returns the value of attribute entropy.
17 18 19 |
# File 'lib/benefits_intake_service/utilities/convert_to_pdf.rb', line 17 def entropy @entropy end |
#original_file ⇒ Object
Returns the value of attribute original_file.
16 17 18 |
# File 'lib/benefits_intake_service/utilities/convert_to_pdf.rb', line 16 def original_file @original_file end |
#original_filename ⇒ Object
Returns the value of attribute original_filename.
16 17 18 |
# File 'lib/benefits_intake_service/utilities/convert_to_pdf.rb', line 16 def original_filename @original_filename end |