quick_codes 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7842cb483a323f37a590e6d9605e1c3c6ffb8ae6
4
- data.tar.gz: 26968feacca55519008a931ea23bd17f680f8db8
3
+ metadata.gz: 3d7e9cc0694debd0e5550267b34a0a36517949b8
4
+ data.tar.gz: 098c7fd2296dfdafb0f246ec551e9c9159951ee0
5
5
  SHA512:
6
- metadata.gz: 8d454e394ccef37ee21c07cdf58e998527b58452960410506cd626f483e40c8d807ec81b190e98fea7047efb185e242d2382d4b517822d0e054c1667bfbab879
7
- data.tar.gz: 3c974206172fbfa4734bb31414d3482e78d77e3b68542eb4aaf397fed630bfc6d20587131277d155375afb3cfe35c96c8ecc27193a608a3916cd6854d798ff67
6
+ metadata.gz: 37b069b089f768b06996166b11a9d0fb7a74b59eccc77d2ba6635198a10ae2ff0235e17d4f88dabcfe75b1a08cf69cca0d4c202c8b6cda20add05f373489f0d2
7
+ data.tar.gz: bf261e85fdb571f73884bc7c7645c4a987979e9c07a0ccfdd3d0c77fb97b6191a214acd95a07d595c6d77f94d177cf4823bd7e6aab1d261b46028f56bc441c14
data/README.md CHANGED
@@ -1,8 +1,7 @@
1
1
  # QuickCodes
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/quick_codes`. To experiment with that code, run `bin/console` for an interactive prompt.
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
- TODO: Write usage instructions here
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/[my-github-username]/quick_codes/fork )
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`)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module QuickCodes
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: quick_codes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alfonso Juan Dillera