Class: Sistrix::Keyword::Seo
- Inherits:
-
Object
- Object
- Sistrix::Keyword::Seo
- Includes:
- Base
- Defined in:
- lib/sistrix/keyword/seo.rb
Defined Under Namespace
Classes: Record
Instance Attribute Summary collapse
-
#credits ⇒ Object
readonly
Returns the value of attribute credits.
-
#date ⇒ Object
readonly
Returns the value of attribute date.
-
#results ⇒ Object
readonly
Returns the value of attribute results.
Instance Method Summary collapse
- #call(options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Seo
constructor
A new instance of Seo.
Methods included from Base
#base_uri, #fetch, #method_name
Constructor Details
#initialize(options = {}) ⇒ Seo
Returns a new instance of Seo.
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/sistrix/keyword/seo.rb', line 11 def initialize( = {}) @options = { 'kw' => nil, 'num' => 5, 'date' => 'today', 'url' => nil, 'api_key' => Sistrix.config.api_key, }.merge() if Sistrix.config.proxy RestClient.proxy = Sistrix.config.proxy end end |
Instance Attribute Details
#credits ⇒ Object (readonly)
Returns the value of attribute credits.
9 10 11 |
# File 'lib/sistrix/keyword/seo.rb', line 9 def credits @credits end |
#date ⇒ Object (readonly)
Returns the value of attribute date.
9 10 11 |
# File 'lib/sistrix/keyword/seo.rb', line 9 def date @date end |
#results ⇒ Object (readonly)
Returns the value of attribute results.
9 10 11 |
# File 'lib/sistrix/keyword/seo.rb', line 9 def results @results end |
Instance Method Details
#call(options = {}) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/sistrix/keyword/seo.rb', line 25 def call( = {}) data = fetch() @credits = data.xpath('/response/credits').first['used'].to_i @date = Time.parse(data.xpath('/response/date').first.to_s) @results = [] data.xpath('/response/answer/result').each do |r| @results << Record.new(r) end self end |