Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/technicalpickles/rankles
Ranking algorithms.
https://github.com/technicalpickles/rankles
Last synced: 3 months ago
JSON representation
Ranking algorithms.
- Host: GitHub
- URL: https://github.com/technicalpickles/rankles
- Owner: technicalpickles
- License: mit
- Created: 2009-05-15T03:21:41.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2013-06-21T16:51:27.000Z (over 11 years ago)
- Last Synced: 2024-04-25T19:01:05.757Z (8 months ago)
- Language: Ruby
- Size: 110 KB
- Stars: 8
- Watchers: 5
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.rdoc
- License: LICENSE
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_countreddit.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_countupdate_attributes! :ranking => reddit_ranking
end
end== Copyright
Copyright (c) 2009 Josh Nichols. See LICENSE for details.