hash_order_helper 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -1
- data/hash_order_helper.gemspec +1 -1
- data/lib/hash_order_helper.rb +9 -0
- 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: 816648a641f45835c25e16f103cdc7dab96b0649
|
4
|
+
data.tar.gz: 7157b16ce4d46d84992d637d6b512733ef06a2cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 189374b3518cc32b0776d0d5d1189433284f58d5c47fb0768f40bc8aed2a909b39687c347a536efcd8a04e11242f07354a8b4a81bdf7a04c74932a2b6175dfc1
|
7
|
+
data.tar.gz: 048161554f245df847ddd29890e53f4fff9525d3ad3f33b031178a3513d1909affde523f959af357a260d9776a977c2e64d20a1d6384347af93c5eec86bfb521
|
data/README.md
CHANGED
@@ -45,6 +45,18 @@ The following methods are added:
|
|
45
45
|
* `last -> Array`
|
46
46
|
* `last(n) -> Array`
|
47
47
|
* `pop -> Array`
|
48
|
-
* `pop(n) -> Array`
|
48
|
+
* `pop(n) -> Array` (alias: `<<`)
|
49
49
|
* `push(hash) -> Hash`
|
50
50
|
* `unshift(hash) -> Hash`
|
51
|
+
* `>>(receiver_hash) -> Hash`
|
52
|
+
|
53
|
+
### `>>` method
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
require 'hash_order_helper'
|
57
|
+
|
58
|
+
hash = {b: 200, a: 100, c: 150}
|
59
|
+
|
60
|
+
{d: 300} >> hash
|
61
|
+
#=> {:d=>300, :b=>200, :a=>100, :c=>150}
|
62
|
+
```
|
data/hash_order_helper.gemspec
CHANGED
data/lib/hash_order_helper.rb
CHANGED
@@ -76,6 +76,7 @@ module HashOrderHelper
|
|
76
76
|
|
77
77
|
self.replace(new_hash)
|
78
78
|
end
|
79
|
+
alias << push
|
79
80
|
|
80
81
|
def unshift(unshift_hash)
|
81
82
|
hash_keys = self.keys - unshift_hash.keys
|
@@ -89,5 +90,13 @@ module HashOrderHelper
|
|
89
90
|
|
90
91
|
self.replace(new_hash)
|
91
92
|
end
|
93
|
+
|
94
|
+
def >>(receiver)
|
95
|
+
unless receiver.is_a?(Hash)
|
96
|
+
raise TypeError, "no implicit conversion of #{receiver.inspect}:#{receiver.class} into Hash"
|
97
|
+
end
|
98
|
+
|
99
|
+
receiver.unshift(self)
|
100
|
+
end
|
92
101
|
end
|
93
102
|
Hash.send(:include, HashOrderHelper)
|
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.3
|
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-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|