Class: Sistrix::Links::Overview

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/sistrix/links/overview.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Base

#base_uri, #fetch, #method_name

Constructor Details

#initialize(options = {}) ⇒ Overview

Returns a new instance of Overview.



11
12
13
14
15
16
17
18
19
20
# File 'lib/sistrix/links/overview.rb', line 11

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

#class_cObject (readonly)

Returns the value of attribute class_c.



9
10
11
# File 'lib/sistrix/links/overview.rb', line 9

def class_c
  @class_c
end

#creditsObject (readonly)

Returns the value of attribute credits.



9
10
11
# File 'lib/sistrix/links/overview.rb', line 9

def credits
  @credits
end

#domainsObject (readonly)

Returns the value of attribute domains.



9
10
11
# File 'lib/sistrix/links/overview.rb', line 9

def domains
  @domains
end

#hostsObject (readonly)

Returns the value of attribute hosts.



9
10
11
# File 'lib/sistrix/links/overview.rb', line 9

def hosts
  @hosts
end

#networksObject (readonly)

Returns the value of attribute networks.



9
10
11
# File 'lib/sistrix/links/overview.rb', line 9

def networks
  @networks
end

#totalObject (readonly)

Returns the value of attribute total.



9
10
11
# File 'lib/sistrix/links/overview.rb', line 9

def total
  @total
end

Instance Method Details

#call(options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/sistrix/links/overview.rb', line 22

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

  @credits  = data.xpath('//credits').first['used'].to_i
  @total    = data.xpath('/response/answer/total').first['num'].to_s.strip.to_i
  @hosts    = data.xpath('/response/answer/hosts').first['num'].to_s.strip.to_i
  @domains  = data.xpath('/response/answer/domains').first['num'].to_s.strip.to_i
  @networks = data.xpath('/response/answer/networks').first['num'].to_s.strip.to_i
  @class_c  = data.xpath('/response/answer/class_c').first['num'].to_s.strip.to_i

  self
end