Sha256: fbaa4ae7814ef13316e79cc47bcd92bafb3b76a5948e4e49220476a096f59c3f

Contents?: true

Size: 1.19 KB

Versions: 16

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

module DocumentExporter
  module Gdoc
    class Material < Gdoc::Base
      def export
        @options[:subfolders] = [DocumentExporter::Gdoc::StudentMaterial::FOLDER_NAME] if document.student_material?
        @options[:subfolders] = [DocumentExporter::Gdoc::TeacherMaterial::FOLDER_NAME] if document.teacher_material?
        unless @options.key?(:subfolders)
          Rails.logger.warn "Material belongs neither to teachers nor to students: #{document.id}"
          @options[:subfolders] = ['Materials']
        end

        handle_vertical_text if document.vertical_text?

        super
      end

      private

      def handle_vertical_text
        data = TextToImage.new(vertical_text, rotate: -90).raw
        filename = "documents/#{document.base_filename}-vtext.png"
        url = S3Service.upload filename, data
        @options[:vertical_text_image_url] = url
      end

      def template_path(name)
        File.join('documents', 'gdoc', 'materials', name)
      end

      def vertical_text_image_data
        TextToImage.new(vertical_text, rotate: -90).raw
      end

      def vertical_text
        document.metadata['vertical_text']
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
lcms-engine-0.5.5 lib/document_exporter/gdoc/material.rb
lcms-engine-0.5.4 lib/document_exporter/gdoc/material.rb
lcms-engine-0.5.3 lib/document_exporter/gdoc/material.rb
lcms-engine-0.5.2 lib/document_exporter/gdoc/material.rb
lcms-engine-0.5.1 lib/document_exporter/gdoc/material.rb
lcms-engine-0.5.0 lib/document_exporter/gdoc/material.rb
lcms-engine-0.4.2 lib/document_exporter/gdoc/material.rb
lcms-engine-0.4.1 lib/document_exporter/gdoc/material.rb
lcms-engine-0.4.0 lib/document_exporter/gdoc/material.rb
lcms-engine-0.3.1 lib/document_exporter/gdoc/material.rb
lcms-engine-0.1.4 lib/document_exporter/gdoc/material.rb
lcms-engine-0.3.0 lib/document_exporter/gdoc/material.rb
lcms-engine-0.1.3 lib/document_exporter/gdoc/material.rb
lcms-engine-0.2.0 lib/document_exporter/gdoc/material.rb
lcms-engine-0.1.2 lib/document_exporter/gdoc/material.rb
lcms-engine-0.1.0 lib/document_exporter/gdoc/material.rb