darthjee-core_ext 1.7.2 → 1.7.3

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: 76f54a19a0bf4ae4892e60d0473ac649c2c63966
4
- data.tar.gz: '0183bd9098a782cfc4792c480435ec3ec93cec0e'
3
+ metadata.gz: 75f22a94cfe27dfcc43f9209d7684ee7cef8546c
4
+ data.tar.gz: 7077d45122b6498b960f459c5fda5c9965138902
5
5
  SHA512:
6
- metadata.gz: 7e24c2851a5462ec6e865e1779a68c4e625c2ea23b95298171261ff33b63ac9d0104ce584e32628c0825d355a4a49bf0b6a4b21b00a5ceaa6bd21dda67483ea4
7
- data.tar.gz: 406126966cfd866c2576eeb1fb112ada5daae171e3ebbc87208b7d3d6fc9a0706c0e78899b52882525e26e6bcb98f4b27aaccefe4e6e7602ffddd66c057bfee1
6
+ metadata.gz: df8e4a2c6c6a6b27611d9ba1d52785323239ec7df2a9239862a1116db897b4112a875d6d279f1a507c7906615247d88375198a9e921e33d9272c6e76d8e46d4c
7
+ data.tar.gz: a71629faafba5302d768e80c556d5deec6249e9a09b14f1a3fd7457e97edf4d14bcd075ca89b89d0c9a2110e2dfcf6e6b86ea3540c43ad334c5e50de1da70b8b
data/README.md CHANGED
@@ -9,7 +9,7 @@ Darthjee/CoreExt
9
9
 
10
10
  Yard Documentation
11
11
  -------------------
12
- https://www.rubydoc.info/gems/darthjee-core_ext/1.7.2
12
+ https://www.rubydoc.info/gems/darthjee-core_ext/1.7.3
13
13
 
14
14
  # Usage
15
15
  This project adds some new methods to the core ruby classes
@@ -28,7 +28,11 @@ module Darthjee
28
28
  # @example Average of array of integer values
29
29
  # array = [1, 2, 3, 4]
30
30
  # array.average # returns 2.5
31
+ #
32
+ # @example An empty array
33
+ # [].average # returns 0
31
34
  def average
35
+ return 0 if empty?
32
36
  sum * 1.0 / length
33
37
  end
34
38
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Darthjee
4
4
  module CoreExt
5
- VERSION = '1.7.2'
5
+ VERSION = '1.7.3'
6
6
  end
7
7
  end
@@ -10,6 +10,10 @@ describe Array do
10
10
  it 'returns the average' do
11
11
  expect(array.average).to eq(2.5)
12
12
  end
13
+
14
+ context 'when array is empty' do
15
+ it { expect([].average).to eq(0) }
16
+ end
13
17
  end
14
18
 
15
19
  describe '#mapk' do
@@ -11,6 +11,10 @@ describe Array do
11
11
  it 'returns the average' do
12
12
  expect(array.average).to eq(2.5)
13
13
  end
14
+
15
+ context 'when array is empty' do
16
+ it { expect([].average).to eq(0) }
17
+ end
14
18
  end
15
19
 
16
20
  describe '#mapk' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: darthjee-core_ext
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.2
4
+ version: 1.7.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Darthjee
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-04 00:00:00.000000000 Z
11
+ date: 2018-10-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport