Sha256: b5b84e97cbf276796ce7899c38ed4f2615a1d8d7ab9d465c2cff0008e2b40ab5

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

# coding: utf-8

module ThinReports
  module Generator
    
    # @abstract
    # @private
    class PDF::Drawer::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_stamp_id(shape)}"
      end
      
      # @see #pdf_stamp_id
      def shape_stamp_id(shape)
        "#{shape.id}#{shape.style.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

3 entries across 3 versions & 1 rubygems

Version Path
thinreports-0.7.6 lib/thinreports/generator/pdf/drawer/base.rb
thinreports-0.7.5 lib/thinreports/generator/pdf/drawer/base.rb
thinreports-0.7.0 lib/thinreports/generator/pdf/drawer/base.rb