hash_order_helper 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +4 -4
- data/hash_order_helper.gemspec +1 -1
- data/lib/hash_order_helper.rb +9 -10
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f9525f6b741b4bc89963ed09244662eee18133aa
|
4
|
+
data.tar.gz: 5b814deff9182fcd07e653cdda9b7830cdee6b6c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 61e7fe158b6bad7e54f8087617c83367cbef2f5d18d2c7f3d9a0a198538f5afd6e135178d10fda46a484a70fd144f60e6c21f142e5beeeefc073afd7ca50f950
|
7
|
+
data.tar.gz: d8cdefbbff3d7419f03c1737f352d0a35699bc489dddc6609f5e7bf97861094e809c9948d1da00ea8636b3b7e849523cc3906965f5e169db8bc9ae0ecb097284
|
data/README.md
CHANGED
@@ -30,7 +30,7 @@ hash = {b: 200, a: 100, c: 150}
|
|
30
30
|
hash.sort_pair
|
31
31
|
#=> {:a=>100, :b=>200, :c=>150}
|
32
32
|
|
33
|
-
hash.unshift(:
|
33
|
+
hash.unshift(d: 300)
|
34
34
|
#=> {:d=>300, :b=>200, :a=>100, :c=>150}
|
35
35
|
```
|
36
36
|
|
@@ -41,10 +41,10 @@ The following methods are added:
|
|
41
41
|
* `sort_pair_by {|key, value| ... } -> Hash`
|
42
42
|
* `sort_pair_by! {|key, value| ... } -> Hash`
|
43
43
|
* `at(nth) -> Array`
|
44
|
-
* `insert(nth,
|
44
|
+
* `insert(nth, hash) -> Hash`
|
45
45
|
* `last -> Array`
|
46
46
|
* `last(n) -> Array`
|
47
47
|
* `pop -> Array`
|
48
48
|
* `pop(n) -> Array`
|
49
|
-
* `push(
|
50
|
-
* `unshift(
|
49
|
+
* `push(hash) -> Hash`
|
50
|
+
* `unshift(hash) -> Hash`
|
data/hash_order_helper.gemspec
CHANGED
data/lib/hash_order_helper.rb
CHANGED
@@ -31,13 +31,13 @@ module HashOrderHelper
|
|
31
31
|
self.to_a.at(nth)
|
32
32
|
end
|
33
33
|
|
34
|
-
def insert(nth,
|
34
|
+
def insert(nth, insert_hash)
|
35
35
|
hash_keys = self.keys
|
36
|
-
hash_keys.insert(nth,
|
36
|
+
hash_keys.insert(nth, *insert_hash.keys)
|
37
37
|
new_hash = {}
|
38
38
|
|
39
39
|
hash_keys.each do |key|
|
40
|
-
value = (key
|
40
|
+
value = insert_hash.has_key?(key) ? insert_hash[key] : self[key]
|
41
41
|
new_hash[key] = value
|
42
42
|
end
|
43
43
|
|
@@ -65,26 +65,25 @@ module HashOrderHelper
|
|
65
65
|
last_values
|
66
66
|
end
|
67
67
|
|
68
|
-
def push(
|
68
|
+
def push(push_hash)
|
69
69
|
hash_keys = self.keys
|
70
|
-
hash_keys.push(
|
70
|
+
hash_keys.push(*push_hash.keys)
|
71
71
|
new_hash = {}
|
72
|
-
|
73
72
|
hash_keys.each do |key|
|
74
|
-
value = (key
|
73
|
+
value = push_hash.has_key?(key) ? push_hash[key] : self[key]
|
75
74
|
new_hash[key] = value
|
76
75
|
end
|
77
76
|
|
78
77
|
self.replace(new_hash)
|
79
78
|
end
|
80
79
|
|
81
|
-
def unshift(
|
80
|
+
def unshift(unshift_hash)
|
82
81
|
hash_keys = self.keys
|
83
|
-
hash_keys.unshift(
|
82
|
+
hash_keys.unshift(*unshift_hash.keys)
|
84
83
|
new_hash = {}
|
85
84
|
|
86
85
|
hash_keys.each do |key|
|
87
|
-
value = (key
|
86
|
+
value = unshift_hash.has_key?(key) ? unshift_hash[key] : self[key]
|
88
87
|
new_hash[key] = value
|
89
88
|
end
|
90
89
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hash_order_helper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|