class Sistrix::Domain::Social::Url

Attributes

credits[R]
facebook[R]
googleplus[R]
history[R]
total[R]
twitter[R]
url[R]

Public Class Methods

new(options = {}) click to toggle source
# File lib/sistrix/domain/social/url.rb, line 12
def initialize(options = {})
  @options = {
    'domain' => nil,
    'history' => nil,
    'api_key' => Sistrix.config.api_key,
  }.merge(options)

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

Public Instance Methods

call(options = {}) click to toggle source
# File lib/sistrix/domain/social/url.rb, line 24
def call(options = {})
  data = fetch(options)

  @credits = data.xpath('//credits').first['used'].to_i
  @votes = []

  current_node = data.xpath('/response/answer/current').first
  @url = current_node['url']
  @total = current_node['total'].to_i
  @facebook = current_node['facebook'].to_i
  @twitter = current_node['twitter'].to_i
  @googleplus = current_node['googleplus'].to_i

  @history = []
  data.xpath('/response/answer/timeline/history').each do |o|
    @history << Record.new(o)
  end

  self
end