Class: SeoParams::Alexa

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

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Alexa

Returns a new instance of Alexa.



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

def initialize(url)
  @url = url
  @response = Nokogiri::HTML(open("http://xml.alexa.com/data?cli=10&dat=nsa&ver=quirk-searchstatus&url=#{url}"))
end

Instance Method Details

#dmozObject



23
24
25
# File 'lib/seo_params/alexa.rb', line 23

def dmoz
   @response.xpath("//alexa/dmoz").length > 0 ? "yes" : "no"
end

#rankObject



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

def rank
  begin
    rank = @response.css("popularity").attr("text").content().to_i
  rescue
    rank = nil
  end
  rank
end