Class: GooglePerspective::Client

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeClient

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

#configObject

Returns the value of attribute config.



10
11
12
# File 'lib/google_perspective/client.rb', line 10

def config
  @config
end

Instance Method Details

#httpObject



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

#urlObject



22
23
24
# File 'lib/google_perspective/client.rb', line 22

def url
  "#{BASE_URL}?key=#{access_key}"
end