Class: PageRankr::Ranks::Google
- Inherits:
-
Object
- Object
- PageRankr::Ranks::Google
- Includes:
- PageRankr::Rank
- Defined in:
- lib/page_rankr/ranks/google.rb,
lib/page_rankr/ranks/google/checksum.rb
Defined Under Namespace
Classes: Checksum
Instance Attribute Summary
Attributes included from PageRankr::Rank
Instance Method Summary collapse
-
#initialize(site) ⇒ Google
constructor
A new instance of Google.
- #regex ⇒ Object
- #request ⇒ Object
Methods included from PageRankr::Rank
Constructor Details
#initialize(site) ⇒ Google
Returns a new instance of Google.
9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/page_rankr/ranks/google.rb', line 9 def initialize(site) @site = site @checksum = Checksum.generate(@site.to_s) request.on_complete do |response| @rank = if response.body =~ regex clean($1) else nil end end end |
Instance Method Details
#regex ⇒ Object
22 23 24 |
# File 'lib/page_rankr/ranks/google.rb', line 22 def regex /Rank_\d+:\d+:(\d+)/ end |
#request ⇒ Object
26 27 28 29 |
# File 'lib/page_rankr/ranks/google.rb', line 26 def request @request ||= Typhoeus::Request.new("http://toolbarqueries.google.com/search", :params => {:client => "navclient-auto", :ch => @checksum, :features => "Rank", :q => "info:#{@site.to_s}"}) end |