Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Ranking algorithms.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 spec
Octocat-spinner-32 .document
Octocat-spinner-32 .gitignore
Octocat-spinner-32 LICENSE
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 VERSION
Octocat-spinner-32 rankles.gemspec
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.

Something went wrong with that request. Please try again.