ar_result_calculations 0.0.4 → 0.0.5
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/CHANGELOG
CHANGED
data/README.textile
CHANGED
@@ -31,6 +31,7 @@ p. All methods take one parameter (column name).
|
|
31
31
|
|sample_variance|Calculates the sample variance of a column (for active record result sets) or self (for an array)|
|
32
32
|
|standard_deviation|Calculates the standard deviation of a column (for active record result sets) or self (for an array)|
|
33
33
|
|median|Calculates the median of a column (for active record result sets) or self (for an array)|
|
34
|
+
|mode|Calculates the mode of a column (for active record result sets) or self (for an array)|
|
34
35
|
|
35
36
|
h1. License
|
36
37
|
|
@@ -117,7 +117,7 @@ module ArResultCalculations
|
|
117
117
|
return nil if data.empty?
|
118
118
|
data = data.sort unless options[:already_sorted]
|
119
119
|
median_position = length / 2
|
120
|
-
length_is_even? ? data[median_position] :
|
120
|
+
length_is_even? ? data[median_position-1..median_position].mean : data[median_position]
|
121
121
|
end
|
122
122
|
|
123
123
|
# Return the mode(s) of a column in an active record result set (or self)
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ar_result_calculations
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 21
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 5
|
10
|
+
version: 0.0.5
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Kip Cole
|