Class: MeaningCloud::Topics

Inherits:
Object
  • Object
show all
Defined in:
lib/meaning_cloud/topics.rb

Overview

A class to hold all topic extraction related code.

:reek:MissingSafeMethod { exclude: [ required_key! ] }

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Topics

Returns a new instance of Topics.



17
18
19
20
21
22
23
24
25
26
# File 'lib/meaning_cloud/topics.rb', line 17

def initialize(options = {})
  @options = {
    of: :json,
    key: configuration.key,
    lang: configuration.language,
    tt: configuration.topic_types,
    ud: configuration.user_dictionary,
    uw: 'y'
  }.merge(options)
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



11
12
13
# File 'lib/meaning_cloud/topics.rb', line 11

def options
  @options
end

Class Method Details

.extract_topics(options = {}) ⇒ Object



13
14
15
# File 'lib/meaning_cloud/topics.rb', line 13

def self.extract_topics(options = {})
  new(options).call
end

Instance Method Details

#callObject



28
29
30
31
32
# File 'lib/meaning_cloud/topics.rb', line 28

def call
  required_key!(options)
  result = RestClient.post(configuration.api_base, options)
  JSON.parse(result)
end