Class: Lcms::Engine::MaterialPreviewGenerator

Inherits:
Object
  • Object
show all
Defined in:
app/services/lcms/engine/material_preview_generator.rb

Overview

Generates and uploads PDF/GDoc files for material

Constant Summary collapse

GDOC_RE =
%r{docs.google.com/document/d/([^/]*)}i.freeze
GDOC_BROKEN_RE =
%r{/open\?id=$}i.freeze
PDF_S3_FOLDER =
'temp-materials-pdf'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(material, options = {}) ⇒ MaterialPreviewGenerator

Returns a new instance of MaterialPreviewGenerator.



15
16
17
18
# File 'app/services/lcms/engine/material_preview_generator.rb', line 15

def initialize(material, options = {})
  @material = material
  @options = options
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



13
14
15
# File 'app/services/lcms/engine/material_preview_generator.rb', line 13

def error
  @error
end

#urlObject (readonly)

Returns the value of attribute url.



13
14
15
# File 'app/services/lcms/engine/material_preview_generator.rb', line 13

def url
  @url
end

Instance Method Details

#performObject



20
21
22
23
24
25
26
27
# File 'app/services/lcms/engine/material_preview_generator.rb', line 20

def perform
  return false unless assign_document

  options[:type] == :pdf ? generate_pdf : generate_gdoc
rescue StandardError => e
  @error = e.message
  false
end