array-subindex 1.0.0 → 1.1.0

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: dce6660ba97882e56b1499cccb5ffaa7b163f56c
4
- data.tar.gz: 342d9a596affd1b653231292780a566a4d343cd4
3
+ metadata.gz: 4f5db374dd0ca57607077d4ad679fc1717ed5e5b
4
+ data.tar.gz: be07e6686cd7f1ba38ff7ae2045263609b6debfe
5
5
  SHA512:
6
- metadata.gz: b8dfc3d648e07ec48deb68697370b249dca2a8959e6a362bb96f339a05619d9e6b0ca2d68246988bff8c35686b467abadcd5e507387f7eb9ee6f2c1644929b7f
7
- data.tar.gz: bd5744c75a8b42d1adf63ba330ea90cb5e0582691f922ac1176b336c33d690299e18aaeae14e49bb7a2317f2ea2ec188ebeed47d9461496b7476d07a4eaeb7bd
6
+ metadata.gz: 1df0dbd96669327b1e64ac5e9e761f206876f073a8489aaf8215f6e8e4f71c3035e47dbf82a76608cacf96a40a1f9bcd26976a02795cca595b86260f34b3b6cc
7
+ data.tar.gz: 5190f223f418ea975a1b52ef3e7177980c00ca3964eb0d73bb6a6e97c8b486b885bee892f2fe9caca711985dcc3e79bd8e7bd21e675169c024ee0de66bf83ac5
data/.gitignore CHANGED
@@ -15,3 +15,4 @@ spec/reports
15
15
  test/tmp
16
16
  test/version_tmp
17
17
  tmp
18
+ *.ruby-*
data/README.md CHANGED
@@ -35,7 +35,7 @@ require 'array/subindex'
35
35
 
36
36
  ## Usage
37
37
 
38
- This gem overrides the Ruby core Array#[] method. That is insanse. If a
38
+ This gem overrides the Ruby core Array#[] method. That is insane. If a
39
39
  "normal" integer is used, the method behaves as normal:
40
40
 
41
41
  ```ruby
@@ -35,9 +35,9 @@ private
35
35
  f_value = f_value.to_s
36
36
  c_value = c_value.to_s
37
37
  f_index = (f_value.length * subindex).to_i
38
- c_index = (c_value.length * (1.0 - subindex)).to_i
38
+ c_index = (c_value.length * subindex).to_i
39
39
  [
40
- f_value.slice(f_index, f_value.length-1),
40
+ f_value.slice(f_index, f_value.length),
41
41
  c_value.slice(0, c_index)
42
42
  ].join
43
43
  end
@@ -1,5 +1,5 @@
1
1
  class Array
2
2
  module Subindex
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -35,6 +35,12 @@ describe 'Array::subindex' do
35
35
  subject[1.001]
36
36
  ).to eq( 2.999)
37
37
  end
38
+
39
+ it "can accept Rational as index" do
40
+ expect(
41
+ subject[Rational(3,2)]
42
+ ).to eq( 1.0 + 1.5)
43
+ end
38
44
  end
39
45
 
40
46
  context "adjacent values are strings" do
@@ -51,7 +57,17 @@ describe 'Array::subindex' do
51
57
  expect(
52
58
  subject[0.25]
53
59
  ).to eq(
54
- "hisi"
60
+ "his"
61
+ )
62
+ end
63
+
64
+ it "deals with uneven subindexes" do
65
+ strings = %w{ foo bar baz }
66
+
67
+ expect(
68
+ strings[1.3]
69
+ ).to eq(
70
+ "bar"
55
71
  )
56
72
  end
57
73
 
@@ -64,6 +80,14 @@ describe 'Array::subindex' do
64
80
  "oob"
65
81
  )
66
82
  end
83
+
84
+ it "can accept Rational as index" do
85
+ expect(
86
+ subject[Rational(1,2)]
87
+ ).to eq(
88
+ "isi"
89
+ )
90
+ end
67
91
  end
68
92
 
69
93
  context "adjacent values are mix of string and numeric" 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.0.0
4
+ version: 1.1.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-10 00:00:00.000000000 Z
11
+ date: 2013-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -60,8 +60,6 @@ extensions: []
60
60
  extra_rdoc_files: []
61
61
  files:
62
62
  - .gitignore
63
- - .ruby-gemset
64
- - .ruby-version
65
63
  - .travis.yml
66
64
  - Gemfile
67
65
  - LICENSE.txt
data/.ruby-gemset DELETED
@@ -1 +0,0 @@
1
- array-subindex
data/.ruby-version DELETED
@@ -1 +0,0 @@
1
- ruby-2.0.0