Class: Sistrix::Domain::Social::Overview

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/sistrix/domain/social/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.



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

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.



10
11
12
# File 'lib/sistrix/domain/social/overview.rb', line 10

def credits
  @credits
end

#facebookObject (readonly)

Returns the value of attribute facebook.



10
11
12
# File 'lib/sistrix/domain/social/overview.rb', line 10

def facebook
  @facebook
end

#googleplusObject (readonly)

Returns the value of attribute googleplus.



10
11
12
# File 'lib/sistrix/domain/social/overview.rb', line 10

def googleplus
  @googleplus
end

#twitterObject (readonly)

Returns the value of attribute twitter.



10
11
12
# File 'lib/sistrix/domain/social/overview.rb', line 10

def twitter
  @twitter
end

Instance Method Details

#call(options = {}) ⇒ Object



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

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

  @credits    = data.xpath('//credits').first['used'].to_i
  @twitter    = data.search('/response/answer/votes[@network="twitter"]').first['value'].to_i
  @facebook   = data.search('/response/answer/votes[@network="facebook"]').first['value'].to_i
  @googleplus = data.search('/response/answer/votes[@network="googleplus"]').first['value'].to_i

  self
end