Class: TheCount::Google::Plus
- Defined in:
- lib/thecount/countable/google.rb
Instance Attribute Summary
Attributes inherited from Countable
Instance Method Summary collapse
- #count(data) ⇒ Object
-
#initialize ⇒ Plus
constructor
A new instance of Plus.
Constructor Details
#initialize ⇒ Plus
Returns a new instance of Plus.
27 28 29 30 31 |
# File 'lib/thecount/countable/google.rb', line 27 def initialize @service_name = "google" @unit = "shares" @value = 0 end |
Instance Method Details
#count(data) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/thecount/countable/google.rb', line 32 def count(data) url = "https://plusone.google.com/u/0/_/+1/fastbutton?url=" url = "#{url}#{CGI::escape(data[:url])}" begin # like penut butter brittle @value = open(url).string.split('window.__SSR = {')[1].split('};')[0].split("'c':")[1].split(",")[0].strip.to_i rescue Exception => e puts e @value = 0 end end |