Sha256: bd90217d6234ea04193ad4891824bc9f06cb5e1733ddaa9f31c89522e9c0905e

Contents?: true

Size: 624 Bytes

Versions: 2

Compression:

Stored size: 624 Bytes

Contents

require 'google/api'
module BabelI18n

  class Translate

    include Google::API

    attr_accessor :text, :key

    def initialize(text)
      @text = text
      @from, @to = nil, nil
    end

    def from(from)
      @from = from
    end

    def to(to)
      @to = to
    end

    def target
      @to
    end

    def source
      @from
    end

    def translate
      google_translate if valid?
    end

    def valid?
      raise "parameter 'text' is necessary to translate" if @text.nil? || @text.empty?
      raise "parameter 'to' is necessary to translate" if @to.nil? || @to.empty?
      true
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
babel_i18n-0.0.3 lib/babel_i18n/translate.rb
babel_i18n-0.0.2 lib/babel_i18n/translate.rb