Class: Wordstream::KeywordTool
- Inherits:
-
Object
- Object
- Wordstream::KeywordTool
- Defined in:
- lib/wordstream.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
Returns the value of attribute client.
-
#keywords ⇒ Object
readonly
Returns the value of attribute keywords.
-
#niches ⇒ Object
readonly
Returns the value of attribute niches.
-
#seeds ⇒ Object
Returns the value of attribute seeds.
Instance Method Summary collapse
- #get_keyword_niches(max_niches) ⇒ Object
- #get_keywords(max_results) ⇒ Object
-
#initialize(client, seeds) ⇒ KeywordTool
constructor
A new instance of KeywordTool.
Constructor Details
#initialize(client, seeds) ⇒ KeywordTool
Returns a new instance of KeywordTool.
41 42 43 |
# File 'lib/wordstream.rb', line 41 def initialize(client, seeds) @client, @seeds = client, seeds end |
Instance Attribute Details
#client ⇒ Object
Returns the value of attribute client.
39 40 41 |
# File 'lib/wordstream.rb', line 39 def client @client end |
#keywords ⇒ Object (readonly)
Returns the value of attribute keywords.
40 41 42 |
# File 'lib/wordstream.rb', line 40 def keywords @keywords end |
#niches ⇒ Object (readonly)
Returns the value of attribute niches.
40 41 42 |
# File 'lib/wordstream.rb', line 40 def niches @niches end |
#seeds ⇒ Object
Returns the value of attribute seeds.
39 40 41 |
# File 'lib/wordstream.rb', line 39 def seeds @seeds end |
Instance Method Details
#get_keyword_niches(max_niches) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/wordstream.rb', line 45 def get_keyword_niches(max_niches) resp = @client.response( @client.class.get('/keywordtool/get_keyword_niches', :query => {:seeds => @seeds, :max_niches => max_niches}) ) @niches = resp.data @niches = resp.data.groupings.collect do |g| keywords = g.matches.collect { |m| Keyword.new(:keyword => resp.data.keywords[m][0], :volume => resp.data.keywords[m][1]) } Niche.new( :title => g.title, :score => g.score, :wordlist => g.wordlist, :keywords => keywords ) end end |
#get_keywords(max_results) ⇒ Object
59 60 61 62 |
# File 'lib/wordstream.rb', line 59 def get_keywords(max_results) resp = @client.response( @client.class.get('/keywordtool/get_keywords', :query => {:seeds => @seeds, :max_results => max_results}) ) @keywords = resp.data.collect { |k| Keyword.new(:keyword => k[0], :volume => k[1]) } end |