Module: C3po::Client

Included in:
C3po
Defined in:
lib/c3po/client.rb

Instance Method Summary collapse

Instance Method Details

#fetch(query) ⇒ String

Query a web service.

Returns a translated string or an array of errors.

Examples:

fetch {:key => 'MYAPIKEY',
       :q => 'Something to translate'
      }

Parameters:

  • Query (Hash)

    containing all the params.

Returns:

  • (String)

    Translated string.

Since:

  • 0.0.1



22
23
24
25
26
27
28
29
30
31
# File 'lib/c3po/client.rb', line 22

def fetch(query)
  request = set_request query
  request.on_complete {|response| process_reponse response}

  hydra = Typhoeus::Hydra.hydra
  hydra.queue request
  hydra.run

  @response if @errors.empty?
end