Class: Sentiment::Client

Inherits:
Object
  • Object
show all
Includes:
HTTParty
Defined in:
lib/sentiment/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_key = nil) ⇒ Client

Get a free api_key @ developer.apphera.com



12
13
14
15
16
# File 'lib/sentiment/client.rb', line 12

def initialize(api_key=nil)
  @api_key = api_key
  @api_key ||= Sentiment.api_key
  @api_path = ''
end

Instance Attribute Details

#api_keyObject (readonly)

Returns the value of attribute api_key.



9
10
11
# File 'lib/sentiment/client.rb', line 9

def api_key
  @api_key
end

Instance Method Details

#sentiment(body, lang) ⇒ Object



18
19
20
21
22
23
# File 'lib/sentiment/client.rb', line 18

def sentiment(body, lang)
  options = {:body => {:body => body, :lang => lang}, :query => self.default_options}
  results = Mash.new(self.class.post('/sentiments', options))
  
  sentiment = results.response.polarity
end