Sha256: 212c5a782451bbd0ca1028420255b8b3a9687f152a09a0d92971873a764c7197

Contents?: true

Size: 755 Bytes

Versions: 2

Compression:

Stored size: 755 Bytes

Contents

# frozen_string_literal: true

require 'dry-struct'

module TranslatorText
  # Includes all the types for the exchanges with the API
  module Types
    include Dry.Types

    Symbol = Types::Symbol.constructor do |str|
      str ? str.to_sym : str
    end

    class << self
      def Sentence(item)
        if item.is_a?(Types::Sentence)
          item
        elsif item.is_a?(String)
          Types::Sentence.new(Text: item)
        end
      end
    end

    module JSON
      def to_json(*args)
        to_hash.to_json(*args)
      end
    end
  end
end

require_relative 'types/sentence'
require_relative 'types/translation'
require_relative 'types/translation_result'
require_relative 'types/alternative'
require_relative 'types/detection_result'

Version data entries

2 entries across 2 versions & 1 rubygems

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