vine 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/vine.rb +15 -2
- metadata +3 -3
data/lib/vine.rb
CHANGED
@@ -1,6 +1,17 @@
|
|
1
|
-
|
1
|
+
module Enumerable
|
2
2
|
|
3
|
-
def
|
3
|
+
def segmentation(n)
|
4
|
+
0.upto(size - 2).to_a.combination(n - 1).to_a.map do |s|
|
5
|
+
[-1, * s, size - 1].each_cons(2).map {|i, j| self[(i + 1)..j] }
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
class Hash
|
13
|
+
|
14
|
+
def access(path)
|
4
15
|
ret = self
|
5
16
|
path.split('.').each do |p|
|
6
17
|
if p.to_i.to_s == p
|
@@ -13,4 +24,6 @@ class Hash
|
|
13
24
|
ret
|
14
25
|
end
|
15
26
|
|
27
|
+
alias :vine :access
|
28
|
+
|
16
29
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2011-12-
|
12
|
+
date: 2011-12-28 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description:
|
15
15
|
email:
|
@@ -41,5 +41,5 @@ rubyforge_project:
|
|
41
41
|
rubygems_version: 1.8.10
|
42
42
|
signing_key:
|
43
43
|
specification_version: 3
|
44
|
-
summary:
|
44
|
+
summary: Nested hash accessing and array segementation
|
45
45
|
test_files: []
|