Module: C3po::Translator
- Included in:
- C3po
- Defined in:
- lib/c3po.rb,
lib/c3po/translator.rb,
lib/c3po/translator/bing.rb,
lib/c3po/translator/google.rb,
lib/c3po/translator/result.rb,
lib/c3po/translator/configuration.rb
Defined Under Namespace
Classes: Bing, Configuration, Google, Result
Instance Method Summary collapse
-
#is ⇒ String
Identify language.
-
#is?(language) ⇒ Boolean
Check language.
-
#languages ⇒ Array
Grab languages list from provider.
-
#translate(from, to) ⇒ String
Translate a string.
Instance Method Details
#is ⇒ String
Identify language.
50 51 52 |
# File 'lib/c3po/translator.rb', line 50 def is @result.language ||= fetch @adaptor.build_detect_query end |
#is?(language) ⇒ Boolean
Check language.
66 67 68 |
# File 'lib/c3po/translator.rb', line 66 def is?(language) language.to_s == is end |
#languages ⇒ Array
Grab languages list from provider.
36 37 38 |
# File 'lib/c3po/translator.rb', line 36 def languages @result.languages ||= fetch @adaptor.build_languages_query end |
#translate(from, to) ⇒ String
Translate a string.
18 19 20 21 22 23 24 |
# File 'lib/c3po/translator.rb', line 18 def translate(from, to) if @result.send(to) @result.send(to) else @result.send("#{to}=", fetch(@adaptor.build_query(from, to))) end end |