Class: Sistrix::Domain::Social::Url
- Inherits:
-
Object
- Object
- Sistrix::Domain::Social::Url
- Includes:
- Base
- Defined in:
- lib/sistrix/domain/social/url.rb
Defined Under Namespace
Classes: Record
Instance Attribute Summary collapse
-
#credits ⇒ Object
readonly
Returns the value of attribute credits.
-
#facebook ⇒ Object
readonly
Returns the value of attribute facebook.
-
#googleplus ⇒ Object
readonly
Returns the value of attribute googleplus.
-
#history ⇒ Object
readonly
Returns the value of attribute history.
-
#total ⇒ Object
readonly
Returns the value of attribute total.
-
#twitter ⇒ Object
readonly
Returns the value of attribute twitter.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #call(options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ Url
constructor
A new instance of Url.
Methods included from Base
#base_uri, #fetch, #method_name
Constructor Details
#initialize(options = {}) ⇒ Url
Returns a new instance of Url.
12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/sistrix/domain/social/url.rb', line 12 def initialize( = {}) @options = { 'domain' => nil, 'history' => nil, 'api_key' => Sistrix.config.api_key, }.merge() if Sistrix.config.proxy RestClient.proxy = Sistrix.config.proxy end end |
Instance Attribute Details
#credits ⇒ Object (readonly)
Returns the value of attribute credits.
9 10 11 |
# File 'lib/sistrix/domain/social/url.rb', line 9 def credits @credits end |
#facebook ⇒ Object (readonly)
Returns the value of attribute facebook.
9 10 11 |
# File 'lib/sistrix/domain/social/url.rb', line 9 def facebook @facebook end |
#googleplus ⇒ Object (readonly)
Returns the value of attribute googleplus.
9 10 11 |
# File 'lib/sistrix/domain/social/url.rb', line 9 def googleplus @googleplus end |
#history ⇒ Object (readonly)
Returns the value of attribute history.
9 10 11 |
# File 'lib/sistrix/domain/social/url.rb', line 9 def history @history end |
#total ⇒ Object (readonly)
Returns the value of attribute total.
9 10 11 |
# File 'lib/sistrix/domain/social/url.rb', line 9 def total @total end |
#twitter ⇒ Object (readonly)
Returns the value of attribute twitter.
9 10 11 |
# File 'lib/sistrix/domain/social/url.rb', line 9 def twitter @twitter end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
9 10 11 |
# File 'lib/sistrix/domain/social/url.rb', line 9 def url @url end |
Instance Method Details
#call(options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/sistrix/domain/social/url.rb', line 24 def call( = {}) data = fetch() @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 |