Sha256: d093587ec5c3a8c6459630185b1700ec5f0e31ff9c256d898601144e7e65c99e

Contents?: true

Size: 1.29 KB

Versions: 7

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

module Thinreports
  module Generator
    class PDF
      module Drawer
        # @abstract
        class Base
          # @param [Thinreports::Generator::PDF::Document] pdf
          # @param [Thinreports::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::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::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::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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
thinreports-0.12.1 lib/thinreports/generator/pdf/drawer/base.rb
thinreports-0.12.0 lib/thinreports/generator/pdf/drawer/base.rb
thinreports-0.11.0 lib/thinreports/generator/pdf/drawer/base.rb
thinreports-0.10.3 lib/thinreports/generator/pdf/drawer/base.rb
thinreports-0.10.2 lib/thinreports/generator/pdf/drawer/base.rb
thinreports-0.10.1 lib/thinreports/generator/pdf/drawer/base.rb
thinreports-0.10.0 lib/thinreports/generator/pdf/drawer/base.rb