Sha256: 1d26517fed6878863f6b172d959cb335b79b332c162c25ef2b6947740e7dfc8a

Contents?: true

Size: 845 Bytes

Versions: 1

Compression:

Stored size: 845 Bytes

Contents

# frozen_string_literal: true

require_relative "operations/text_to_image"
require_relative "operations/image_to_image"
require_relative "operations/upscale"
require_relative "operations/masking"

module Roseflow
  module StabilityAI
    class OperationHandler
      OPERATION_CLASSES = {
        text_to_image: Operations::TextToImage,
        image_to_image: Operations::ImageToImage,
        upscale: Operations::Upscale,
        masking: Operations::Masking,
      }

      def initialize(operation, options = {})
        @operation = operation
        @options = options
      end

      def call
        operation_class.new(@options)
      end

      private

      def operation_class
        OPERATION_CLASSES.fetch(@operation) do
          raise ArgumentError, "Invalid operation: #{@operation}"
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
roseflow-stabilityai-0.1.0 lib/roseflow/stabilityai/operation_handler.rb