Sha256: e3d45a135bc46c56a8e6957c6e798931ac7ec1b3cb5652b983364e1ea8e45d28

Contents?: true

Size: 1.15 KB

Versions: 1

Compression:

Stored size: 1.15 KB

Contents

# frozen_string_literal: true

module Thinreports
  module Core
    module Shape
      def Interface(parent, format) # rubocop:disable Naming/MethodName
        find_by_type(format.type)::Interface.new(parent, format)
      end

      def Format(type) # rubocop:disable Naming/MethodName
        find_by_type(type)::Format
      end

      module_function :Interface, :Format

      # rubocop:disable Metrics/CyclomaticComplexity
      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_relative 'shape/style'
require_relative 'shape/manager'
require_relative 'shape/base'
require_relative 'shape/basic'
require_relative 'shape/text'
require_relative 'shape/text_block'
require_relative 'shape/image_block'
require_relative 'shape/list'
require_relative 'shape/page_number'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
thinreports-0.10.1 lib/thinreports/core/shape.rb