Class: Popularity::GooglePlus

Inherits:
Crawler
  • Object
show all
Defined in:
lib/popularity/networks/google_plus.rb

Instance Attribute Summary

Attributes inherited from Crawler

#url

Instance Method Summary collapse

Methods inherited from Crawler

#async_done?, #fetch, #fetch_async, #has_response?, #host, #initialize, #name, #response, #response_json, #to_json, #valid?

Constructor Details

This class inherits a constructor from Popularity::Crawler

Instance Method Details

#as_json(options = {}) ⇒ Object



8
9
10
# File 'lib/popularity/networks/google_plus.rb', line 8

def as_json(options = {})
  {"plus_ones" => plus_ones}
end

#plus_onesObject



3
4
5
6
# File 'lib/popularity/networks/google_plus.rb', line 3

def plus_ones
  matches = response.scan(/window.__SSR = {c\: (\d+.\d+E?\d+)/) 
  matches.flatten.first.to_f.to_i
end

#totalObject



12
13
14
# File 'lib/popularity/networks/google_plus.rb', line 12

def total
  plus_ones
end