Class: Clarification::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/clarification/client.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeClient

Returns a new instance of Client.


6
7
8
9
10
11
12
# File 'lib/clarification/client.rb', line 6

def initialize
  raise "No Configuration Found." if Clarification.configuration.nil?
  @active_public_models = Clarification.configuration.default_public_models
  @last_response = nil
  @search = Search.new
  @train = Train.new
end

Instance Attribute Details

#active_public_modelsObject (readonly)

Returns the value of attribute active_public_models


4
5
6
# File 'lib/clarification/client.rb', line 4

def active_public_models
  @active_public_models
end

#last_responseObject (readonly)

Returns the value of attribute last_response


4
5
6
# File 'lib/clarification/client.rb', line 4

def last_response
  @last_response
end

#searchObject (readonly)

Returns the value of attribute search


4
5
6
# File 'lib/clarification/client.rb', line 4

def search
  @search
end

#trainObject (readonly)

Returns the value of attribute train


4
5
6
# File 'lib/clarification/client.rb', line 4

def train
  @train
end

Instance Method Details

#predict(url) ⇒ Object


14
15
16
17
18
19
# File 'lib/clarification/client.rb', line 14

def predict(url)
  requester = Requester.new(@active_public_models)
  response = requester.get(url)
  @last_response = Enrich.new(response).run
  return @last_response
end

#set_models(model_array) ⇒ Object


21
22
23
24
25
26
27
# File 'lib/clarification/client.rb', line 21

def set_models(model_array)
  if model_array.class != Array
    raise "Clarification expects an array of models."
  end
  
  @active_public_models = model_array
end