Class: Sistrix::Domain::Social::Latest

Inherits:
Object
  • Object
show all
Includes:
Base
Defined in:
lib/sistrix/domain/social/latest.rb

Defined Under Namespace

Classes: Record

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Base

#base_uri, #fetch, #method_name

Constructor Details

#initialize(options = {}) ⇒ Latest

Returns a new instance of Latest.



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

def initialize(options = {})
  @options = {
    'domain' => nil,
    'network' => nil,
    'num' => 10,
    '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.



9
10
11
# File 'lib/sistrix/domain/social/latest.rb', line 9

def credits
  @credits
end

#urlsObject (readonly)

Returns the value of attribute urls.



9
10
11
# File 'lib/sistrix/domain/social/latest.rb', line 9

def urls
  @urls
end

Instance Method Details

#call(options = {}) ⇒ Object



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

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

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

  self
end