Class: GooglePR
- Inherits:
-
Object
- Object
- GooglePR
- Defined in:
- lib/google_pr.rb
Instance Attribute Summary collapse
-
#checksum ⇒ Object
Returns the value of attribute checksum.
-
#domain ⇒ Object
Returns the value of attribute domain.
Instance Method Summary collapse
-
#check ⇒ Object
Return a number between 0 to 10, that represents the Google PageRank.
-
#initialize(domain) ⇒ GooglePR
constructor
A new instance of GooglePR.
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
#checksum ⇒ Object
Returns the value of attribute checksum.
100 101 102 |
# File 'lib/google_pr.rb', line 100 def checksum @checksum end |
#domain ⇒ Object
Returns the value of attribute domain.
100 101 102 |
# File 'lib/google_pr.rb', line 100 def domain @domain end |
Instance Method Details
#check ⇒ Object
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 = "#{}?" + 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 |