Class: GooglePR

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(domain) ⇒ GooglePR

Returns a new instance of GooglePR.



102
103
104
105
# File 'lib/google_pr.rb', line 102

def initialize(domain)
  self.domain = domain
  self.checksum = GoogleChecksum.generate("info:#{self.domain}")
end

Instance Attribute Details

#checksumObject

Returns the value of attribute checksum.



100
101
102
# File 'lib/google_pr.rb', line 100

def checksum
  @checksum
end

#domainObject

Returns the value of attribute domain.



100
101
102
# File 'lib/google_pr.rb', line 100

def domain
  @domain
end

Instance Method Details

#checkObject

Return a number between 0 to 10, that represents the Google PageRank



108
109
110
111
112
# File 'lib/google_pr.rb', line 108

def check
  url = "#{toolbar_url}?" + params.collect {|k,v| "#{k}=#{v}"}.join("&")
  res = HTTParty.get(url, :headers => {"User-Agent" => "Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Trident/5.0)" }, :format => :raw)
  res.to_s.match(/Rank_\d+:\d+:(\d+)/) ? $1.to_i : nil
end