Sha256: c46e5dd86120f831ae1781be792e818c5bbba70383e18d8565cd26ea476d77b4

Contents?: true

Size: 567 Bytes

Versions: 4

Compression:

Stored size: 567 Bytes

Contents

#encoding: UTF-8
module Termit
  class UrlConstructor
    Host = "http://translate.google.com"

    def initialize options
      @options = options
    end

    def url
      @options[:talk] ? construct_sound_url : construct_text_url
    end

    private

    def construct_text_url
      "#{Host}/translate_a/t?client=t&sl=#{@options[:source_lang]}&tl=#{@options[:target_lang]}&hl=pl&sc=2&ie=UTF-8&oe=UTF-8&prev=enter&ssel=0&tsel=0&"
    end

    def construct_sound_url
      "#{Host}/translate_tts?tl=#{@options[:target_lang]}&ie=UTF-8&oe=UTF-8"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
termit-2.10.2 lib/termit/url_constructor.rb
termit-2.10.1 lib/termit/url_constructor.rb
termit-2.10.0 lib/termit/url_constructor.rb
termit-2.0.9 lib/termit/url_constructor.rb