class OpenCalais::Client

Attributes

current_options[RW]

Public Class Methods

new(options={}) { |self| ... } click to toggle source
# File lib/open_calais/client.rb, line 24
def initialize(options={}, &block)
  setup(options)
  yield(self) if block_given?
end

Public Instance Methods

analyze(text, opts={}) click to toggle source
# File lib/open_calais/client.rb, line 38
def analyze(text, opts={})
  raise 'Specify a value for the text' unless (text && text.length > 0)
  options = current_options.merge(opts)

  response = connection(options).post do |request|
    request.body = text
  end
  OpenCalais::Response.new(response, options)
end
Also aliased as: enrich
enrich(text, opts={})

using analyze as a standard method name enrich is more OpenCalais specific

Alias for: analyze
setup(options={}) click to toggle source
# File lib/open_calais/client.rb, line 29
def setup(options={})
  opts = Hash[options.map{ |k, v| [k.to_sym, v] }]
  opts = OpenCalais.options.merge(opts)
  self.current_options = opts
  Configuration.keys.each do |key|
    send("#{key}=", opts[key])
  end
end