Class: VibeSort::Sorter

Inherits:
Object
  • Object
show all
Defined in:
lib/vibe_sort/sorter.rb

Overview

Sorter dispatches the sorting operation to the configured provider adapter

Constant Summary collapse

PROVIDER_CLASSES =
{
  openai: Providers::OpenAI,
  anthropic: Providers::Anthropic,
  gemini: Providers::Gemini,
  groq: Providers::Groq,
  spacexai: Providers::SpaceXAI
}.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Sorter

Initialize a new Sorter

Parameters:



19
20
21
# File 'lib/vibe_sort/sorter.rb', line 19

def initialize(config)
  @config = config
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



14
15
16
# File 'lib/vibe_sort/sorter.rb', line 14

def config
  @config
end

Instance Method Details

#perform(array) ⇒ Hash

Perform the sorting operation via the configured provider's API

Parameters:

  • array (Array)

    Array of numbers and/or strings to sort

Returns:

  • (Hash)

    Result hash with :success, :sorted_array, and optional :error keys

Raises:



28
29
30
# File 'lib/vibe_sort/sorter.rb', line 28

def perform(array)
  PROVIDER_CLASSES.fetch(config.provider).new(config).perform(array)
end