Module: PageRankr::Rank

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#rankObject (readonly) Also known as: tracked

Returns the value of attribute rank.



3
4
5
# File 'lib/page_rankr/rank.rb', line 3

def rank
  @rank
end

Instance Method Details

#clean(rank) ⇒ Object



16
17
18
# File 'lib/page_rankr/rank.rb', line 16

def clean(rank)
  rank.to_s.to_i
end

#initialize(site) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/page_rankr/rank.rb', line 6

def initialize(site)
  @site = site
  
  request.on_complete do |response|
    html = Nokogiri::HTML(response.body)
    @rank = clean(html.search(xpath))
    @rank = nil if @rank.zero?
  end
end