module ExcelReports
  module IssuesAndConcernsReports
    class IssuesAndConcernsReport
      def initialize(video)
        @video = video
      end

      def to_xls
        IssuesAndConcernsWorksheet.new(
          workbook,
          IssuesAndConcernsReportPresenter.new(video)
        ).build
        package.to_stream.read
      end

      def filename
        "#{video.file.filename.to_s.parameterize}_issues-and-concerns.xlsx"
      end

      private

      attr_reader :video

      def workbook
        @workbook ||= package.workbook
      end

      def package
        @package ||= Axlsx::Package.new
      end
    end
  end
end
