Class: OpenCalais::Client
- Inherits:
-
Object
- Object
- OpenCalais::Client
- Includes:
- Connection
- Defined in:
- lib/open_calais/client.rb
Constant Summary
Constants included from Connection
OpenCalais::Connection::ALLOWED_OPTIONS
Instance Attribute Summary collapse
-
#current_options ⇒ Object
Returns the value of attribute current_options.
Instance Method Summary collapse
- #analyze(text, opts = {}) ⇒ Object (also: #enrich)
-
#initialize(options = {}) {|_self| ... } ⇒ Client
constructor
A new instance of Client.
- #setup(options = {}) ⇒ Object
Methods included from Connection
#connection, #merge_default_options
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ Client
Returns a new instance of Client.
25 26 27 28 |
# File 'lib/open_calais/client.rb', line 25 def initialize(={}, &block) setup() yield(self) if block_given? end |
Instance Attribute Details
#current_options ⇒ Object
Returns the value of attribute current_options.
14 15 16 |
# File 'lib/open_calais/client.rb', line 14 def end |
Instance Method Details
#analyze(text, opts = {}) ⇒ Object Also known as: enrich
39 40 41 42 43 44 45 46 47 |
# File 'lib/open_calais/client.rb', line 39 def analyze(text, opts={}) raise 'Specify a value for the text' unless (text && text.length > 0) = .merge(opts) response = connection().post do |request| request.body = text end OpenCalais::Response.new(response, ) end |
#setup(options = {}) ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'lib/open_calais/client.rb', line 30 def setup(={}) opts = Hash[.map{ |k, v| [k.to_sym, v] }] opts = OpenCalais..merge(opts) self. = opts Configuration.keys.each do |key| send("#{key}=", opts[key]) end end |