Class: GoogleWebTranslate::API
- Inherits:
-
Object
- Object
- GoogleWebTranslate::API
- Defined in:
- lib/google_web_translate/api.rb
Overview
interface to the google web translation api
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ API
constructor
A new instance of API.
- #languages ⇒ Object
- #translate(string, from, to) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ API
Returns a new instance of API.
7 8 9 10 11 12 13 |
# File 'lib/google_web_translate/api.rb', line 7 def initialize( = {}) @dt = [:dt] || DEFAULT_DT @token_ttl = [:token_ttl] || DEFAULT_TOKEN_TTL @debug = [:debug] @http_client = [:http_client] || HTTPClient.new() @rate_limit = [:rate_limit] || DEFAULT_RATE_LIMIT end |
Instance Method Details
#languages ⇒ Object
20 21 22 23 24 25 |
# File 'lib/google_web_translate/api.rb', line 20 def languages @languages ||= begin html = fetch_main html.scan(/\['(\w{2})','(\w{2})'\]/).flatten.uniq.sort end end |