public
Description: Ranking algorithms.
Homepage:
Clone URL: git://github.com/technicalpickles/rankles.git
Thu May 14 20:40:29 -0700 2009
commit  3d92339eec1067b257363ea20e0ef70198a7c706
tree    54e1cd5cdb83df4d702823b7fcb9c24a9744d964
parent  7296d30af69eb747ea149480a66d409c34d4c5d9
name age message
file .document Thu May 14 20:21:41 -0700 2009 Initial commit to rankles. [technicalpickles]
file .gitignore Thu May 14 20:21:41 -0700 2009 Initial commit to rankles. [technicalpickles]
file LICENSE Thu May 14 20:21:41 -0700 2009 Initial commit to rankles. [technicalpickles]
file README.rdoc Thu May 14 20:37:45 -0700 2009 Updated docs. [technicalpickles]
file Rakefile Thu May 14 20:26:29 -0700 2009 Initial import. [technicalpickles]
file VERSION Thu May 14 20:37:33 -0700 2009 Version bump to 0.0.2 [technicalpickles]
directory lib/ Thu May 14 20:37:45 -0700 2009 Updated docs. [technicalpickles]
file rankles.gemspec Thu May 14 20:40:29 -0700 2009 Hrm, why no version update? [technicalpickles]
directory spec/ Thu May 14 20:26:29 -0700 2009 Initial import. [technicalpickles]
README.rdoc

rankles

Rankles is a collection of ranking algorithms (technically only one at the moment) implemented in Ruby.

The idea is simple. Give Rankles some data, and it will give you a number. You probably want to sort based on this number.

Quick example:

    reddit = Rankles::Reddit.new :date => entry.published_at,
                                 :upvotes => entry.cached_upvotes_count,
                                 :downvotes => entry.cached_downvotes_count

    reddit.to_f

If you’re dealing with ActiveRecord objects, you can actually assign the Rankles object to a float field, and it will handle converstion:

    class Entry < ActiveRecord::Base
      # ommitted
      def calculate_ranking
        reddit_ranking = Rankles::Reddit.new :date => entry.published_at,
                                     :upvotes => entry.cached_upvotes_count,
                                     :downvotes => entry.cached_downvotes_count

        update_attributes! :ranking => reddit_ranking
      end
    end

Copyright

Copyright © 2009 Josh Nichols. See LICENSE for details.