Class: Webstalker::Flickr
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
Methods inherited from Base
Constructor Details
This class inherits a constructor from Webstalker::Base
Instance Method Details
#tags ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/webstalker/flickr.rb', line 3 def url = "http://www.flickr.com/photos/#{username}/tags/" doc = Nokogiri::HTML(open(url)) w=[] doc.css("#TagCloud a").each do |link| t = link.text.strip if t !~ /#{Regexp.escape(username)}/ w << [link.text.strip, link.attr("style").match(/(\d+)/)[0].to_i ] end end w=w.sort_by {|e| e.last*-1} = Set.new(w[0,[:limit]||3].map{|e| e.first}) if w.size > 10 6.times do << w.at(rand(w.size)).first end end end |