Class: TermExtraction::Yahoo

Inherits:
TermExtraction show all
Defined in:
lib/term_extraction/yahoo.rb

Instance Attribute Summary

Attributes inherited from TermExtraction

#api_key, #context

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from TermExtraction

#canonical_name, #initialize

Constructor Details

This class inherits a constructor from TermExtraction

Class Method Details

.canonical_nameObject



26
27
28
# File 'lib/term_extraction/yahoo.rb', line 26

def canonical_name
  'yahoo'
end

Instance Method Details

#termsObject



7
8
9
10
11
12
13
# File 'lib/term_extraction/yahoo.rb', line 7

def terms
  begin
    Crack::XML.parse(remote_xml)['ResultSet']['Result']
  rescue
    []
  end
end

#uriObject



15
16
17
18
19
20
21
22
23
# File 'lib/term_extraction/yahoo.rb', line 15

def uri
  api_uri = URI.parse(gateway)
  api_uri.query = {
     'appid'   => @api_key,
     'output'  => 'xml',
     'context' => @context
  }.map { |k,v| "#{URI.escape(k || '')}=#{URI.escape(v || '')}" }.join('&')
  api_uri
end