Sha256: 683d4b3f7f61313cd2acd0b8141137bade791bac6163b83a31dd2e0898f79126

Contents?: true

Size: 670 Bytes

Versions: 3

Compression:

Stored size: 670 Bytes

Contents

module ThousandIsland
  module Components
    class Base

      attr_reader :pdf, :options

      def initialize(pdf, args=nil)
        @options = args || self.defaults
        @pdf = pdf
      end

      def draw(&block)
        if repeated?
          render_all &block
        else
          render &block
        end
      end

      def render_all(&block)
        pdf.repeat :all do
          render &block
        end
      end

      def render(&block)
        raise NotImplementedError
      end

      def repeated?
        false
      end

      def self.defaults
        {}
      end

      def defaults
        self.class.defaults
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thousand_island-0.1.1 lib/thousand_island/components/base.rb
thousand_island-0.1.0 lib/thousand_island/components/base.rb
thousand_island-0.0.1 lib/thousand_island/components/base.rb