Class: SeoParams::GooglePlus

Inherits:
Object
  • Object
show all
Defined in:
lib/seo_params/google_plus.rb

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ GooglePlus

Returns a new instance of GooglePlus.



10
11
12
# File 'lib/seo_params/google_plus.rb', line 10

def initialize(url)
  @url = url.match(/^(https?:\/\/)/) ? url : 'http://' + url
end

Instance Method Details

#plus_onesObject



14
15
16
17
18
19
# File 'lib/seo_params/google_plus.rb', line 14

def plus_ones
  api_url = "https://plusone.google.com/_/+1/fastbutton?url=#{CGI.escape(@url)}"
  response = Nokogiri::HTML(open(api_url))
  total_plus_ones = response.css("#aggregateCount")
  convert_count(total_plus_ones.text())
end