Sha256: 69fe6798b1dedd9d54f2bf80f51ffb641583276925c85e6bda46584a1df2cc2a

Contents?: true

Size: 473 Bytes

Versions: 2

Compression:

Stored size: 473 Bytes

Contents

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
        if h = detectedLanguage['language']
          h.to_sym
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
translator-text-0.2.0 lib/translator_text/types/translation_result.rb
translator-text-0.1.0 lib/translator_text/types/translation_result.rb