Sha256: 11d5b679d8f992ff2aa0c41cf51f40d93b54e1d6ee669ad7f028dc51fc75cbbf

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

# coding: utf-8

module Thinreports
  module Core

    module Shape
      def Interface(parent, format)
        find_by_type(format.type)::Interface.new(parent, format)
      end

      def Format(type)
        find_by_type(type)::Format
      end

      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

      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 PageNumber::TYPE_NAME then PageNumber
        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'
require 'thinreports/core/shape/page_number'

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
thinreports-0.8.2 lib/thinreports/core/shape.rb
thinreports-0.8.1 lib/thinreports/core/shape.rb
thinreports-0.8.0 lib/thinreports/core/shape.rb