Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/technicalpickles/rankles

Ranking algorithms.
https://github.com/technicalpickles/rankles

Last synced: 3 months ago
JSON representation

Ranking algorithms.

Awesome Lists containing this project

README

        

= 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 (c) 2009 Josh Nichols. See LICENSE for details.