shard-container 0.6.5 → 0.6.6
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 +4 -4
- data/lib/shard.rb +10 -14
- data/readme.md +7 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdf303852783a0efa7b97ef420b9e96809919691
|
4
|
+
data.tar.gz: 4a24a3d20b7c3253ad80102bfc07d2ecf9261a9d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bded12eb6a5c88082c85063ff0a50b7a64664ce9d79ae17551db5109f98701d2934ae522aaff42d2a9fff2f2eb624f920b8f9ee84b611a0a0a3da27beb027424
|
7
|
+
data.tar.gz: d74bbc5ecfbfc52c21af9479b701929534b366f05eb4e5e59119481f1a0aed7f2e72aa186140b4b6d9c7fa096aad9aab369597ef2eb29563b9c64b8a3f16b362
|
data/lib/shard.rb
CHANGED
@@ -26,7 +26,7 @@ class Shard
|
|
26
26
|
#deletes an element from the values array based on type parameter
|
27
27
|
def delete(element,type=nil)
|
28
28
|
case type
|
29
|
-
#deleting by key
|
29
|
+
#deleting by key
|
30
30
|
when :key
|
31
31
|
#recursively delete all structs who's key matches element
|
32
32
|
@values.delete_if{|e| e.values[0]==element}
|
@@ -45,19 +45,17 @@ class Shard
|
|
45
45
|
@meta.is_empty=@meta.size<0
|
46
46
|
end
|
47
47
|
|
48
|
-
|
49
|
-
#>deletion
|
50
|
-
#delete by key (shortcut)
|
48
|
+
#delete by key (alias method)
|
51
49
|
def delKey(element)
|
52
50
|
delete(element,:key)
|
53
51
|
end
|
54
52
|
|
55
|
-
#delete by value (
|
53
|
+
#delete by value (alias method)
|
56
54
|
def delVal(element)
|
57
55
|
delete(element,:val)
|
58
56
|
end
|
59
57
|
|
60
|
-
#delete by position or range (
|
58
|
+
#delete by position or range (alias)
|
61
59
|
def delPos(element,endnum=nil)
|
62
60
|
case endnum.class.name
|
63
61
|
when 'Fixnum'
|
@@ -69,30 +67,28 @@ class Shard
|
|
69
67
|
end
|
70
68
|
end
|
71
69
|
|
72
|
-
|
73
|
-
#prune keys
|
70
|
+
#prune shard by keys
|
74
71
|
def pKeys
|
75
72
|
prune(:key)
|
76
73
|
end
|
77
|
-
#prune values
|
74
|
+
#prune shard by values
|
78
75
|
def pVals
|
79
76
|
prune(:val)
|
80
77
|
end
|
81
|
-
#prune utils
|
78
|
+
#prune shard by utils
|
82
79
|
def pUtils
|
83
80
|
prune(:util)
|
84
81
|
end
|
85
|
-
#prune all elements
|
82
|
+
#prune all shard elements
|
86
83
|
def pAll
|
87
84
|
prune(:key,:value,:util)
|
88
85
|
end
|
89
86
|
|
90
|
-
|
91
|
-
#deletion
|
87
|
+
#deletion aliases
|
92
88
|
alias :keyDelete :delKey
|
93
89
|
alias :valDelete :delVal
|
94
90
|
alias :indexDelete :delPos
|
95
|
-
#pruning
|
91
|
+
#pruning aliases
|
96
92
|
alias :pruneKeys :pKeys
|
97
93
|
alias :pruneVals :pVals
|
98
94
|
alias :pruneUtils :pUtils
|
data/readme.md
CHANGED
@@ -6,18 +6,21 @@
|
|
6
6
|
## Methods
|
7
7
|
> #### Initialization
|
8
8
|
> A shard's initial id parameter can be set to either a String, Symbol, or Fixnum.
|
9
|
+
>
|
9
10
|
> test1=Shard.new(:testShard)
|
10
11
|
> test2=Shard.new('testShard') #different id than the test1
|
11
12
|
> test3=Shard.new(3)
|
12
13
|
>
|
13
14
|
> #### Adding to a shard
|
14
15
|
> Adding to a shard can be done one of two ways.
|
16
|
+
>
|
15
17
|
> test=Shard.new(:test)
|
16
18
|
> test.add('foo',:bar,123)
|
17
19
|
> test.values<<['foo',:bar,123] #this can be cleaned up later
|
18
20
|
>
|
19
21
|
> #### Deleting shard elements
|
20
22
|
> Deleting from a shard is also easily done.
|
23
|
+
>
|
21
24
|
> test=Shard.new(:test) #initialize the shard
|
22
25
|
> test.add('foo',:bar,123) #add to the shard
|
23
26
|
>
|
@@ -27,6 +30,7 @@
|
|
27
30
|
>
|
28
31
|
> #### Correction
|
29
32
|
> Shards also supply a few formatting methods.
|
33
|
+
>
|
30
34
|
> test=Shard.new(:test) #initialize the shard
|
31
35
|
> x.values<<[1,2,3] #add to the shard
|
32
36
|
> => [[1, 2, 3]]
|
@@ -35,6 +39,7 @@
|
|
35
39
|
>
|
36
40
|
> #### Pruning
|
37
41
|
> Pruning a shard's unique keys, values, or utilities is accomplished using the following aliases, or a raw `Shard.prune` method call using any combination of `:key`,`:val`, or `:util` as parameters.
|
42
|
+
>
|
38
43
|
> Shard.pruneKeys #prune by keys
|
39
44
|
> Shard.pruneVals #prune by values
|
40
45
|
> Shard.pruneUtils #prune by utilities
|
@@ -42,6 +47,7 @@
|
|
42
47
|
>
|
43
48
|
> #### Cleaning shards
|
44
49
|
> Cleaning a shard using the `.clean` method returns an Array (nested, if more than one k/v/u set is selected) of readable sets with all elements in their original types.
|
50
|
+
>
|
45
51
|
> Shard.clean #cleans and returns entire shard
|
46
52
|
> Shard.clean(0) #cleans and returns shard element at index 0
|
47
|
-
> Shard.clean(0,2) #cleans and returns shard elements at indexes 0 to 2
|
53
|
+
> Shard.clean(0,2) #cleans and returns shard elements at indexes 0 to 2
|