class TheCount::Google::Plus

Public Class Methods

new() click to toggle source
# File lib/thecount/countable/google.rb, line 27
def initialize
  @service_name = "google"
  @unit = "shares"
  @value = 0
end

Public Instance Methods

count(data) click to toggle source
# 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