Sha256: 4b7ba3b3dd32849a142a49d78f23ea2935aa3386e4a1ec52b2b0b6b2fa255206

Contents?: true

Size: 625 Bytes

Versions: 1

Compression:

Stored size: 625 Bytes

Contents

module Webstalker
  class Flickr < Webstalker::Base
    def tags
      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}

      tags = Set.new(w[0,options[:limit]||3].map{|e| e.first})
      if w.size > 10
        6.times do
          tags << w.at(rand(w.size)).first
        end
      end

      tags
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webstalker-0.1.0 lib/webstalker/flickr.rb