Class: GooglePerspective::Client
- Inherits:
-
Object
- Object
- GooglePerspective::Client
- Extended by:
- Forwardable
- Defined in:
- lib/google_perspective/client.rb
Constant Summary collapse
- BASE_URL =
'https://commentanalyzer.googleapis.com/v1alpha1/comments:analyze'
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
- #http ⇒ Object
-
#initialize ⇒ Client
constructor
A new instance of Client.
- #post(data = {}) ⇒ Object
- #url ⇒ Object
Constructor Details
#initialize ⇒ Client
Returns a new instance of Client.
14 15 16 |
# File 'lib/google_perspective/client.rb', line 14 def initialize @config = GooglePerspective.configuration end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
10 11 12 |
# File 'lib/google_perspective/client.rb', line 10 def config @config end |
Instance Method Details
#http ⇒ Object
26 27 28 |
# File 'lib/google_perspective/client.rb', line 26 def http @http ||= HTTP.accept(:json) end |
#post(data = {}) ⇒ Object
18 19 20 |
# File 'lib/google_perspective/client.rb', line 18 def post(data = {}) http.post(url, json: data).parse end |
#url ⇒ Object
22 23 24 |
# File 'lib/google_perspective/client.rb', line 22 def url "#{BASE_URL}?key=#{access_key}" end |