array-subindex 1.1.0 → 1.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4f5db374dd0ca57607077d4ad679fc1717ed5e5b
4
- data.tar.gz: be07e6686cd7f1ba38ff7ae2045263609b6debfe
3
+ metadata.gz: c5bd593c29d9bf506cfc8c8c4236c027f643788c
4
+ data.tar.gz: 3b500bdf72d283175ad127a0486c4a4d26266913
5
5
  SHA512:
6
- metadata.gz: 1df0dbd96669327b1e64ac5e9e761f206876f073a8489aaf8215f6e8e4f71c3035e47dbf82a76608cacf96a40a1f9bcd26976a02795cca595b86260f34b3b6cc
7
- data.tar.gz: 5190f223f418ea975a1b52ef3e7177980c00ca3964eb0d73bb6a6e97c8b486b885bee892f2fe9caca711985dcc3e79bd8e7bd21e675169c024ee0de66bf83ac5
6
+ metadata.gz: a082683202f921635b63259829fcdc06bfd791bd36308954d1fb38da092c8abd4ee79382bd05a77650f44879c5f90e129cace7c1e148b95c5c56ab6c37eb6f42
7
+ data.tar.gz: cccdcaa249aea013da28564fbccedf398145fce90f735d5cbf2307acc08d4a39c552d5c5892c3aca94f71f3e61fbcbec77f5f5ff531fed0fa510bdadbee7948e
data/README.md CHANGED
@@ -57,15 +57,14 @@ adjacent indexes, adds them, and returns them. For example:
57
57
  It also works for unequal devisions (e.g. indexes other than 0.5):
58
58
 
59
59
  ```ruby
60
- [1,2,3][0.25] == 1.75
61
- # 1/4 of index 0 + 3/4 of index 1
60
+ [1,2,3][0.25] == 1.25
61
+ # 3/4 of index 0 + 1/4 of index 1
62
62
  ```
63
63
 
64
64
  In the case of irrational divisions, the results are rounded:
65
65
 
66
66
  ```ruby
67
- [1,2,3][1.001] == 2.999
68
- but rounded to 2.999
67
+ [1,2,3][1.001] == 2.001
69
68
  ```
70
69
 
71
70
  For arrays of strings, a concatination of portions of the values are used:
@@ -105,4 +104,7 @@ Distributed under the [WTFPL](https://github.com/rlespinasse/WTFPL) license.
105
104
 
106
105
  ## Contributing
107
106
 
108
- 1. Don't. Stop encouraging me to commit these kinds of sin.
107
+ 1. Don't. Stop encouraging me to commit these kinds of sin.
108
+
109
+ [![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/xunker/array-subindex/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
110
+
@@ -26,8 +26,8 @@ class Array
26
26
  private
27
27
 
28
28
  def subindex_as_number(subindex, f_value, c_value)
29
- f_fractional = f_value.to_f * subindex
30
- c_fractional = c_value.to_f * (1.0 - subindex)
29
+ f_fractional = f_value.to_f * (1.0 - subindex)
30
+ c_fractional = c_value.to_f * subindex
31
31
  f_fractional + c_fractional
32
32
  end
33
33
 
@@ -1,5 +1,5 @@
1
1
  class Array
2
2
  module Subindex
3
- VERSION = "1.1.0"
3
+ VERSION = "1.2.0"
4
4
  end
5
5
  end
@@ -23,17 +23,17 @@ describe 'Array::subindex' do
23
23
  end
24
24
 
25
25
  it "will add parts unequally" do
26
- # 1/4 of index 0 + 3/4 of index 1
26
+ # 3/4 of index 0 + 1/4 of index 1
27
27
  expect(
28
28
  subject[0.25]
29
- ).to eq( 0.25 + 1.5)
29
+ ).to eq( 0.75 + 0.5)
30
30
  end
31
31
 
32
32
  it "will round values" do
33
- # expect 0.001 of index 1 and 0.998 index 2, but rounded to 2.999
33
+ # expect 0.998 of index 1 and 0.001 index 2, but rounded
34
34
  expect(
35
35
  subject[1.001]
36
- ).to eq( 2.999)
36
+ ).to eq( 2.001)
37
37
  end
38
38
 
39
39
  it "can accept Rational as index" do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: array-subindex
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Nielsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-11 00:00:00.000000000 Z
11
+ date: 2013-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler