rank 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/rank.rb +4 -4
- data/lib/rank/version.rb +1 -1
- metadata +4 -4
data/lib/rank.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
module Rank
|
2
|
-
#
|
2
|
+
# Compare two objects. By default the order is ascending (:asc) but descending can be specified with (:desc).
|
3
3
|
def self.compare a, b, *attributes
|
4
4
|
attributes.each do |attribute, order, conversion|
|
5
5
|
a_attribute = self.perform_conversion a[attribute], conversion
|
@@ -20,7 +20,7 @@ module Rank
|
|
20
20
|
return 0
|
21
21
|
end
|
22
22
|
|
23
|
-
#
|
23
|
+
# Add rank to a list of objects. It will automatically sort the objects and observe ties.
|
24
24
|
def self.add objects, *attributes
|
25
25
|
options = { :ties => true, :sort => true }.merge(extract_options! attributes)
|
26
26
|
|
@@ -40,11 +40,11 @@ module Rank
|
|
40
40
|
return objects
|
41
41
|
end
|
42
42
|
|
43
|
-
def self.extract_options! args
|
43
|
+
def self.extract_options! args #:nodoc:
|
44
44
|
args.last.is_a?(::Hash) ? args.pop : {}
|
45
45
|
end
|
46
46
|
|
47
|
-
def self.perform_conversion value, conversion
|
47
|
+
def self.perform_conversion value, conversion #:nodoc:
|
48
48
|
begin
|
49
49
|
if conversion.nil? || conversion == :none
|
50
50
|
value
|
data/lib/rank/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 2
|
9
|
+
version: 0.0.2
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Pan Thomakos
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2011-01-
|
17
|
+
date: 2011-01-20 00:00:00 -08:00
|
18
18
|
default_executable:
|
19
19
|
dependencies: []
|
20
20
|
|
@@ -69,6 +69,6 @@ rubyforge_project: rank
|
|
69
69
|
rubygems_version: 1.3.7
|
70
70
|
signing_key:
|
71
71
|
specification_version: 3
|
72
|
-
summary: rank-0.0.
|
72
|
+
summary: rank-0.0.2
|
73
73
|
test_files:
|
74
74
|
- test/rank_test.rb
|