quick_codes 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/README.md +13 -5
- data/lib/overloads/array.rb +11 -2
- data/lib/quick_codes/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d7e9cc0694debd0e5550267b34a0a36517949b8
|
4
|
+
data.tar.gz: 098c7fd2296dfdafb0f246ec551e9c9159951ee0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37b069b089f768b06996166b11a9d0fb7a74b59eccc77d2ba6635198a10ae2ff0235e17d4f88dabcfe75b1a08cf69cca0d4c202c8b6cda20add05f373489f0d2
|
7
|
+
data.tar.gz: bf261e85fdb571f73884bc7c7645c4a987979e9c07a0ccfdd3d0c77fb97b6191a214acd95a07d595c6d77f94d177cf4823bd7e6aab1d261b46028f56bc441c14
|
data/README.md
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
# QuickCodes
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
TODO: Delete this and the text above, and describe your gem
|
3
|
+
Quick codes overloads Ruby classes with additional functionalities that,
|
4
|
+
otherwise, would not be available to them.
|
6
5
|
|
7
6
|
## Installation
|
8
7
|
|
@@ -20,9 +19,18 @@ Or install it yourself as:
|
|
20
19
|
|
21
20
|
$ gem install quick_codes
|
22
21
|
|
22
|
+
## Version Updates
|
23
|
+
### 0.1.0
|
24
|
+
* Initial upload YEY!
|
25
|
+
* Implemented stdevp for arrays.
|
26
|
+
|
27
|
+
### 0.1.1
|
28
|
+
* Implemented merge_hashes_using_key for arrays.
|
29
|
+
|
23
30
|
## Usage
|
24
31
|
|
25
|
-
|
32
|
+
Installing Quick codes would add the functionalities to your Ruby
|
33
|
+
objects.
|
26
34
|
|
27
35
|
## Development
|
28
36
|
|
@@ -32,7 +40,7 @@ To install this gem onto your local machine, run `bundle exec rake install`. To
|
|
32
40
|
|
33
41
|
## Contributing
|
34
42
|
|
35
|
-
1. Fork it ( https://github.com/
|
43
|
+
1. Fork it ( https://github.com/adillera/quick_codes/fork )
|
36
44
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
37
45
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
38
46
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/lib/overloads/array.rb
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
class Array
|
2
2
|
# For reference:
|
3
3
|
# https://www.mathsisfun.com/data/standard-deviation-formulas.html
|
4
|
-
|
5
4
|
# Population standard deviation
|
6
5
|
def stdevp
|
7
6
|
return false unless self.length > 0
|
8
|
-
|
9
7
|
arr = self
|
10
8
|
# Step 1: Get the mean
|
11
9
|
mean = arr.inject(:+).to_f / arr.length.to_f
|
@@ -21,4 +19,15 @@ class Array
|
|
21
19
|
# Step 4: Square root of step 3
|
22
20
|
Math.sqrt(step_3).to_f
|
23
21
|
end
|
22
|
+
|
23
|
+
# For reference:
|
24
|
+
# http://stackoverflow.com/questions/27249327/how-to-merge-hashes-if-a-specified-keys-values-are-same-in-a-array
|
25
|
+
# Credits to http://stackoverflow.com/users/390819/w0lf for the solution
|
26
|
+
def merge_hashes_using_key(key)
|
27
|
+
return false unless self.length > 0
|
28
|
+
|
29
|
+
arr = self
|
30
|
+
|
31
|
+
arr.group_by{ |h| h[key] }.collect{ |_, hs| hs.reduce(:merge) }
|
32
|
+
end
|
24
33
|
end
|
data/lib/quick_codes/version.rb
CHANGED