Class: Adroit::Reputation

Inherits:
Object
  • Object
show all
Defined in:
lib/stackoverflow-rep/api.rb

Instance Method Summary collapse

Instance Method Details

#find(userid) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/stackoverflow-rep/api.rb', line 3

def find userid
	begin
		@so_url = "http://stackoverflow.com/users/#{userid}"
		@so_page = Nokogiri::HTML(open(@so_url))
		@reputation = 0
		@so_page.css('div.reputation span a').each do |rep|
			@reputation = rep.content.to_i
		end
		@reputation
	rescue
		p 'stackoverflow-rep : Error -> Invalid USER ID'
		return
	end
end