Class: TimesTags
Class Method Summary collapse
- .api_key ⇒ Object
- .config ⇒ Object
-
.config_path ⇒ Object
Path to the times_topics.yml file.
- .config_path=(value) ⇒ Object
- .geographic_search(name) ⇒ Object
- .organization_search(name) ⇒ Object
- .person_search(name) ⇒ Object
- .search(query, type) ⇒ Object
- .subject_search(name) ⇒ Object
Class Method Details
.api_key ⇒ Object
9 10 11 |
# File 'lib/times_tags.rb', line 9 def self.api_key config['api_key'] end |
.config ⇒ Object
13 14 15 |
# File 'lib/times_tags.rb', line 13 def self.config @config ||= YAML::load_file(config_path) end |
.config_path ⇒ Object
Path to the times_topics.yml file.
18 19 20 21 22 23 24 25 |
# File 'lib/times_tags.rb', line 18 def self.config_path if @config_path.nil? if defined?(Rails.env) @config_path = File.join(RAILS_ROOT, 'config', 'times_topics.yml') end end @config_path end |
.config_path=(value) ⇒ Object
27 28 29 |
# File 'lib/times_tags.rb', line 27 def self.config_path= value @config_path = value end |
.geographic_search(name) ⇒ Object
39 40 41 |
# File 'lib/times_tags.rb', line 39 def self.geographic_search(name) get('/suggest', :query => { :query => name, :filter => '(Geo)', 'api-key' => api_key}) end |
.organization_search(name) ⇒ Object
35 36 37 |
# File 'lib/times_tags.rb', line 35 def self.organization_search(name) get('/suggest', :query => { :query => name, :filter => '(Org)', 'api-key' => api_key}) end |
.person_search(name) ⇒ Object
31 32 33 |
# File 'lib/times_tags.rb', line 31 def self.person_search(name) get('/suggest', :query => { :query => name, :filter => '(Per)', 'api-key' => api_key}) end |
.search(query, type) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/times_tags.rb', line 47 def self.search(query, type) case type when /person/ person_search(query) when /organization/ organization_search(query) when /geographic/ geographic_search(query) when /subject|description/ subject_search(query) else person_search(query) end end |
.subject_search(name) ⇒ Object
43 44 45 |
# File 'lib/times_tags.rb', line 43 def self.subject_search(name) get('/suggest', :query => { :query => name, :filter => '(Des)', 'api-key' => api_key}) end |