Sha256: 4296634d5848b18bf95a59158d94a8941c07de35df11022fc07facda3bd39038

Contents?: true

Size: 1.45 KB

Versions: 5

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

module Thinreports
  module BasicReport
    module Generator
      class PDF
        module Drawer
          # @abstract
          class Base
            # @param [Thinreports::BasicReport::Generator::PDF::Document] pdf
            # @param [Thinreports::BasicReport::Core::Shape::Manager::Format] format
            def initialize(pdf, format)
              @pdf = pdf
              @format = format
              @stamps = []
              @draw_at = nil
            end

            # @abstract
            def draw
              raise NotImplementedError
            end

            private

            # @param [Thinreports::BasicReport::Core::Shape::Base::Internal] shape
            # @return [String]
            def pdf_stamp_id(shape)
              "#{@format.identifier}#{shape.identifier}"
            end

            # @overload pdf_stamp(shape_id)
            #   @param [String] shape_id
            # @overload pdf_stamp(shape)
            #   @param [Thinreports::BasicReport::Core::Shape::Base::Internal] shape
            def pdf_stamp(shape)
              shape = pdf_stamp_id(shape) unless shape.is_a?(::String)
              @pdf.stamp(shape, @draw_at)
            end

            # @param [Thinreports::BasicReport::Core::Shape::Base::Internal] shape
            def create_pdf_stamp(shape, &block)
              @pdf.create_stamp(pdf_stamp_id(shape), &block)
            end
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
thinreports-0.14.2 lib/thinreports/basic_report/generator/pdf/drawer/base.rb
thinreports-0.14.1 lib/thinreports/basic_report/generator/pdf/drawer/base.rb
thinreports-0.14.0 lib/thinreports/basic_report/generator/pdf/drawer/base.rb
thinreports-0.13.1 lib/thinreports/basic_report/generator/pdf/drawer/base.rb
thinreports-0.13.0 lib/thinreports/basic_report/generator/pdf/drawer/base.rb