Sha256: ba730ebd777eb721fd915688fefa8b6de587e6353ad50099e84d65e409bd5a79

Contents?: true

Size: 1.19 KB

Versions: 1

Compression:

Stored size: 1.19 KB

Contents

# coding: utf-8

module ThinReports
  module Generator::PDF::Drawer
    
    # @abstract
    # @private
    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

1 entries across 1 versions & 1 rubygems

Version Path
thinreports-0.7.7 lib/thinreports/generator/pdf/drawer/base.rb