Class: Iknow::Item

Inherits:
Base
  • Object
show all
Defined in:
lib/iknow/model/item.rb

Defined Under Namespace

Classes: Cue, Response

Constant Summary collapse

ATTRIBUTES =
[:sentences, :response, :cue, :id]

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

attributes, #attributes, deserialize, #deserialize

Constructor Details

#initialize(params = {}) ⇒ Item

Returns a new instance of Item.



44
45
46
47
48
49
50
51
52
# File 'lib/iknow/model/item.rb', line 44

def initialize(params = {})
  @id = params['id'].to_i
  @sentences = []
  params['sentences'].each do |sentence|
    @sentences << Iknow::Sentence.new(sentence)
  end
  @response = params['response'] ? Iknow::Item::Response.new(params['response']) : nil
  @cue      = Iknow::Item::Cue.new(params['cue'])
end

Class Method Details

.extract(text, params = {}) ⇒ Object



38
39
40
41
42
# File 'lib/iknow/model/item.rb', line 38

def self.extract(text, params = {})
  params[:text] = text
  response = Iknow::RestClient::Item.extract(params)
  self.deserialize(response) || []
end

.matching(keyword, params = {}) ⇒ Object



32
33
34
35
36
# File 'lib/iknow/model/item.rb', line 32

def self.matching(keyword, params = {})
  params[:keyword] = keyword
  response = Iknow::RestClient::Item.matching(params)
  self.deserialize(response) || []
end

.recent(params = {}) ⇒ Object



27
28
29
30
# File 'lib/iknow/model/item.rb', line 27

def self.recent(params = {})
  response = Iknow::RestClient::Item.recent(params)
  self.deserialize(response) || []
end