Sha256: eec6560b74f3f1b9667500041a0b471c056ecea9d21acbcdac2db64b608afcba

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

# coding: utf-8

module ThinReports
  module Core
    
    module Shape
      # @private
      def Interface(parent, format)
        find_by_type(format.type)::Interface.new(parent, format)
      end
      
      # @private
      def Format(type)
        find_by_type(type)::Format
      end
      
      # @private
      def Configuration(type)
        klass = find_by_type(type)
        unless klass.const_defined?(:Configuration)
          raise ThinReports::Errors::NoConfigurationFound, type
        end
        klass.const_get(:Configuration)
      end
      
      module_function :Interface, :Format, :Configuration
      
      # @private
      def self.find_by_type(type)
        case type
        when TextBlock::TYPE_NAME  then TextBlock
        when ImageBlock::TYPE_NAME then ImageBlock
        when List::TYPE_NAME       then List
        when Text::TYPE_NAME       then Text
        when *Basic::TYPE_NAMES    then Basic
        else
          raise ThinReports::Errors::UnknownShapeType
        end
      end
    end
  
  end
end

require 'thinreports/core/shape/style'
require 'thinreports/core/shape/manager'
require 'thinreports/core/shape/base'
require 'thinreports/core/shape/basic'
require 'thinreports/core/shape/text'
require 'thinreports/core/shape/text_block'
require 'thinreports/core/shape/image_block'
require 'thinreports/core/shape/list'

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thinreports-0.7.6 lib/thinreports/core/shape.rb
thinreports-0.7.5 lib/thinreports/core/shape.rb
thinreports-0.7.0 lib/thinreports/core/shape.rb