Sha256: 681615093a8fffdb1624288778bcdba06a027c7f9212873977514bbeae057074

Contents?: true

Size: 1.13 KB

Versions: 5

Compression:

Stored size: 1.13 KB

Contents

# coding: utf-8

module Thinreports
  module Generator::PDF::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)
        unless shape.is_a?(::String)
          shape = pdf_stamp_id(shape)
        end
        @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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
thinreports-0.9.1 lib/thinreports/generator/pdf/drawer/base.rb
thinreports-0.9.0 lib/thinreports/generator/pdf/drawer/base.rb
thinreports-0.8.2 lib/thinreports/generator/pdf/drawer/base.rb
thinreports-0.8.1 lib/thinreports/generator/pdf/drawer/base.rb
thinreports-0.8.0 lib/thinreports/generator/pdf/drawer/base.rb