class PainfulTranslate::Client
Public Class Methods
instance()
click to toggle source
# File lib/painful_translate/client.rb, line 5 def instance @instance ||= new end
Public Instance Methods
translate(*keys, options)
click to toggle source
# File lib/painful_translate/client.rb, line 10 def translate(*keys, options) opts = _normalize options PainfulTranslate::GoogleTranslator.new.tap do |t| t.strings = keys t.to = opts[:to] t.from = opts[:from] t.session = _session end.translations end
Private Instance Methods
_normalize(opts={})
click to toggle source
# File lib/painful_translate/client.rb, line 29 def _normalize(opts={}) { to: opts[:to] || _uh_oh!, from: opts[:from] || :auto } end
_raw_session()
click to toggle source
# File lib/painful_translate/client.rb, line 25 def _raw_session @session ||= Capybara::Session.new :selenium end
_session()
click to toggle source
# File lib/painful_translate/client.rb, line 21 def _session _raw_session.tap(&:reset!) end
_uh_oh!()
click to toggle source
# File lib/painful_translate/client.rb, line 36 def _uh_oh! raise NoTargetLanguage, "You didn't specific a target language to translate into" end