Class: RelatedWord::Service::SemanticService

Inherits:
Object
  • Object
show all
Defined in:
lib/related_word/service/semantic_service.rb

Constant Summary collapse

"http://semantic-link.com/related.php?word="

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(word) ⇒ SemanticService

Returns a new instance of SemanticService.



15
16
17
# File 'lib/related_word/service/semantic_service.rb', line 15

def initialize(word)
  @word = word
end

Instance Attribute Details

#wordObject (readonly)

Returns the value of attribute word.



13
14
15
# File 'lib/related_word/service/semantic_service.rb', line 13

def word
  @word
end

Instance Method Details

#findObject



19
20
21
22
23
24
25
# File 'lib/related_word/service/semantic_service.rb', line 19

def find
  Timeout::timeout(Configure.timeout) do
    resp      = Net::HTTP.get_response(word_uri)
    json_resp = JSON.parse(resp.body)
    Formatter::SemanticFormatter.new(json_resp).format
  end
end