Sha256: aad6b16cafbb5912d11653e03c5b7bf54d4e8781c566fc81acc65a344383f228

Contents?: true

Size: 504 Bytes

Versions: 2

Compression:

Stored size: 504 Bytes

Contents

# frozen_string_literal: true

module TranslatorText
  module Types
    class TranslationResult < Dry::Struct
      include Types::JSON

      transform_keys(&:to_sym)

      attribute :translations, Types::Array.of(Translation)
      attribute :detectedLanguage, Types::Hash.default({})

      # Returns the detected language
      #
      # @return [Symbol] the language
      def detected_language
        return unless (h = detectedLanguage['language'])

        h.to_sym
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
translator-text-0.3.1 lib/translator_text/types/translation_result.rb
translator-text-0.3.0 lib/translator_text/types/translation_result.rb