Class: Sistrix::Domain::Competitors::Seo
- Inherits:
-
Object
- Object
- Sistrix::Domain::Competitors::Seo
- Includes:
- Base
- Defined in:
- lib/sistrix/domain/competitors/seo.rb
Defined Under Namespace
Classes: Record
Instance Attribute Summary collapse
-
#competitors ⇒ Object
readonly
Returns the value of attribute competitors.
-
#credits ⇒ Object
readonly
Returns the value of attribute credits.
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.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/sistrix/domain/competitors/seo.rb', line 12 def initialize( = {}) @options = { 'num' => 5, 'domain' => nil, 'api_key' => Sistrix.config.api_key, }.merge() if Sistrix.config.proxy RestClient.proxy = Sistrix.config.proxy end end |
Instance Attribute Details
#competitors ⇒ Object (readonly)
Returns the value of attribute competitors.
10 11 12 |
# File 'lib/sistrix/domain/competitors/seo.rb', line 10 def competitors @competitors end |
#credits ⇒ Object (readonly)
Returns the value of attribute credits.
10 11 12 |
# File 'lib/sistrix/domain/competitors/seo.rb', line 10 def credits @credits end |
Instance Method Details
#call(options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/sistrix/domain/competitors/seo.rb', line 24 def call( = {}) data = fetch() @credits = data.xpath('//credits').first['used'].to_i @competitors = [] data.xpath('//answer/result').each do |r| @competitors << Record.new(r) end self end |