Project

rankles

0.0
No commit activity in last 3 years
No release in over 3 years
Ranking algorithms.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Runtime

active_support
~> 3.0.0
 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 © 2009 Josh Nichols. See LICENSE for details.