Class: Sistrix::Domain

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/sistrix/domain.rb,
lib/sistrix/domain/age.rb,
lib/sistrix/domain/pages.rb,
lib/sistrix/domain/overview.rb,
lib/sistrix/domain/pagerank.rb,
lib/sistrix/domain/social/top.rb,
lib/sistrix/domain/social/url.rb,
lib/sistrix/domain/kwcount/sem.rb,
lib/sistrix/domain/kwcount/seo.rb,
lib/sistrix/domain/social/latest.rb,
lib/sistrix/domain/competitors/us.rb,
lib/sistrix/domain/competitors/sem.rb,
lib/sistrix/domain/competitors/seo.rb,
lib/sistrix/domain/social/overview.rb,
lib/sistrix/domain/sichtbarkeitsindex.rb

Defined Under Namespace

Modules: Social Classes: Age, Competitors, Kwcount, Overview, Pagerank, Pages, Record, Sichtbarkeitsindex

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Base

#base_uri, #fetch, #method_name

Constructor Details

#initialize(options = {}) ⇒ Domain

Returns a new instance of Domain.



10
11
12
13
14
15
16
17
18
19
# File 'lib/sistrix/domain.rb', line 10

def initialize(options = {})
  @options = {
    'domain' => nil,
    'api_key' => Sistrix.config.api_key,
  }.merge(options)

  if Sistrix.config.proxy
    RestClient.proxy = Sistrix.config.proxy
  end
end

Instance Attribute Details

#creditsObject (readonly)

Returns the value of attribute credits.



8
9
10
# File 'lib/sistrix/domain.rb', line 8

def credits
  @credits
end

#optionsObject (readonly)

Returns the value of attribute options.



8
9
10
# File 'lib/sistrix/domain.rb', line 8

def options
  @options
end

Instance Method Details

#call(options = {}) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
# File 'lib/sistrix/domain.rb', line 21

def call(options = {})
  data = fetch(options)

  @credits = data.xpath('//credits').first['used'].to_i
  @options = []
  data.xpath('//answer/option').each do |o|
    @options << Record.new(o)
  end

  self
end