Sha256: 1cd02c0d03c2142a6cd60812e8ff45446d12d65cd15698456a1aa92c1315cc1b

Contents?: true

Size: 967 Bytes

Versions: 19

Compression:

Stored size: 967 Bytes

Contents

# frozen_string_literal: true

require_relative '../helpers/hash'
require_relative 'default'

module NanoBot
  module Logic
    module Cartridge
      module Adapter
        def self.expression(cartridge, interface, direction, language)
          adapter = [
            {
              exists: (Helpers::Hash.fetch(cartridge, [:interfaces, direction, :adapter]) || {}).key?(language),
              value: Helpers::Hash.fetch(cartridge, [:interfaces, direction, :adapter, language])
            },
            {
              exists: (Helpers::Hash.fetch(cartridge,
                                           [:interfaces, interface, direction, :adapter]) || {}).key?(language),
              value: Helpers::Hash.fetch(cartridge, [:interfaces, interface, direction, :adapter, language])
            }
          ].filter { |candidate| candidate[:exists] }.last

          return nil if adapter.nil?

          adapter[:value]
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
nano-bots-3.4.0 logic/cartridge/adapters.rb
nano-bots-3.3.0 logic/cartridge/adapters.rb
nano-bots-3.2.0 logic/cartridge/adapters.rb
nano-bots-3.0.1 logic/cartridge/adapters.rb
nano-bots-3.0.0 logic/cartridge/adapters.rb
nano-bots-2.5.1 logic/cartridge/adapters.rb
nano-bots-2.5.0 logic/cartridge/adapters.rb
nano-bots-2.4.1 logic/cartridge/adapters.rb
nano-bots-2.4.0 logic/cartridge/adapters.rb
nano-bots-2.3.0 logic/cartridge/adapters.rb
nano-bots-2.2.0 logic/cartridge/adapters.rb
nano-bots-2.1.0 logic/cartridge/adapters.rb
nano-bots-2.0.0 logic/cartridge/adapters.rb
nano-bots-1.2.0 logic/cartridge/adapters.rb
nano-bots-1.1.2 logic/cartridge/adapters.rb
nano-bots-1.1.1 logic/cartridge/adapters.rb
nano-bots-1.1.0 logic/cartridge/adapters.rb
nano-bots-1.0.1 logic/cartridge/adapters.rb
nano-bots-1.0.0 logic/cartridge/adapters.rb