multi_key_hash 0.1.0 → 0.1.1
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/.editorconfig +9 -0
- data/.gitignore +2 -0
- data/.travis.yml +4 -0
- data/README.md +63 -9
- data/lib/multi_key_hash/version.rb +1 -1
- data/multi_key_hash.gemspec +3 -3
- data/spec/multi_key_hash_spec.rb +1 -1
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2f03ecdb16e6595d62966217390c6d2f6d7ee4c
|
4
|
+
data.tar.gz: a5543922eb48c0b323ca82834ba23ca8a1776d5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8e76ca955eca25d20c087807129fcbe5eb8a6860acec64e710258ea7b47c2ef62224822f4faff92996d5c0351035caf11396d1619504ed009608c5bf6ee923e2
|
7
|
+
data.tar.gz: 85ba4f52bb8c932e951976ea5635cdf595133e236429ccb5c93ee6515493b40480b206c3f85c3765b4a54cdc8c2ee97052bb9417f9622a41b5d39f25d6ceee20
|
data/.editorconfig
ADDED
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
# MultiKeyHash
|
2
2
|
|
3
|
-
|
3
|
+
> Hash with multiple keys for same value, symbol/string-indifferent key access.
|
4
4
|
|
5
|
-
|
5
|
+
[![build-url][build-url-svg]][build-url]
|
6
6
|
|
7
7
|
## Installation
|
8
8
|
|
@@ -22,18 +22,72 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
#### Creating new multiple keys hash and accessing it's keys
|
26
26
|
|
27
|
-
|
27
|
+
```ruby
|
28
|
+
require 'multi_key_hash'
|
29
|
+
|
30
|
+
multi_hash = MultiKeyHash.new({%w[one two three] => 'number', %i[a b c] => 'letter', 'single' => 'value'})
|
31
|
+
|
32
|
+
multi_hash['one'] # number
|
33
|
+
multi_hash[:a] # letter
|
34
|
+
multi_hash['single'] # value
|
35
|
+
```
|
36
|
+
|
37
|
+
#### Modifying values inside hash
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
multi_hash = MultiKeyHash.new({%w[one two three] => 'number', %i[a b c] => 'letter', 'single' => 'value'})
|
41
|
+
|
42
|
+
multi_hash['one'] = 'first_number' # first_number
|
43
|
+
multi_hash['two'] # number
|
44
|
+
|
45
|
+
multi_hash[:a] = 'first_letter' # first_letter
|
46
|
+
multi_hash[:b] # letter
|
47
|
+
```
|
48
|
+
|
49
|
+
#### Adding new keys to hash
|
28
50
|
|
29
|
-
|
51
|
+
```ruby
|
52
|
+
multi_hash = MultiKeyHash.new({%w[one two three] => 'number', %i[a b c] => 'letter', 'single' => 'value'})
|
53
|
+
|
54
|
+
multi_hash[:language] = 'english' # single key
|
55
|
+
multi_hash[[:ruby, :js, :php]] = 'programming_language' # multiple keys
|
56
|
+
```
|
30
57
|
|
31
|
-
|
58
|
+
#### Deleting keys from hash
|
32
59
|
|
33
|
-
|
60
|
+
```ruby
|
61
|
+
multi_hash = MultiKeyHash.new({%w[one two three] => 'number', %i[a b c] => 'letter', 'single' => 'value'})
|
62
|
+
|
63
|
+
multi_hash.delete(:a)
|
64
|
+
multi_hash[:b] #letter
|
34
65
|
|
35
|
-
|
66
|
+
multi_hash.delete('one')
|
67
|
+
multi_hash['two'] #number
|
68
|
+
```
|
69
|
+
|
70
|
+
#### Converting to regular hash
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
multi_hash = MultiKeyHash.new({%w[one two three] => 'number', %i[a b c] => 'letter', 'single' => 'value'})
|
74
|
+
|
75
|
+
multi_hash.to_h
|
76
|
+
|
77
|
+
# {
|
78
|
+
# 'one' => 'number',
|
79
|
+
# 'two' => 'number',
|
80
|
+
# 'three' => 'number',
|
81
|
+
# :a => 'letter',
|
82
|
+
# :b => 'letter',
|
83
|
+
# :c => 'letter',
|
84
|
+
# 'single' => 'value'
|
85
|
+
# }
|
86
|
+
```
|
36
87
|
|
37
88
|
## License
|
38
89
|
|
39
|
-
|
90
|
+
[MIT License](https://opensource.org/licenses/MIT).
|
91
|
+
|
92
|
+
[build-url]: https://travis-ci.org/SamirHodzic/multi_key_hash
|
93
|
+
[build-url-svg]: https://travis-ci.org/SamirHodzic/multi_key_hash.svg?branch=master
|
data/multi_key_hash.gemspec
CHANGED
@@ -9,9 +9,9 @@ Gem::Specification.new do |spec|
|
|
9
9
|
spec.authors = ['SamirHodzic']
|
10
10
|
spec.email = ['samir.sgd@gmail.com']
|
11
11
|
|
12
|
-
spec.summary = '
|
13
|
-
spec.description = '
|
14
|
-
spec.homepage = '
|
12
|
+
spec.summary = 'MultiKeyHash gem for ruby'
|
13
|
+
spec.description = 'Multiple key hashes for ruby'
|
14
|
+
spec.homepage = 'https://github.com/SamirHodzic/multi_key_hash'
|
15
15
|
spec.license = 'MIT'
|
16
16
|
|
17
17
|
spec.files = `git ls-files`.split($/)
|
data/spec/multi_key_hash_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: multi_key_hash
|
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
|
- SamirHodzic
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
-
description:
|
55
|
+
description: Multiple key hashes for ruby
|
56
56
|
email:
|
57
57
|
- samir.sgd@gmail.com
|
58
58
|
executables:
|
@@ -61,6 +61,7 @@ executables:
|
|
61
61
|
extensions: []
|
62
62
|
extra_rdoc_files: []
|
63
63
|
files:
|
64
|
+
- ".editorconfig"
|
64
65
|
- ".gitignore"
|
65
66
|
- ".rspec"
|
66
67
|
- ".travis.yml"
|
@@ -75,7 +76,7 @@ files:
|
|
75
76
|
- multi_key_hash.gemspec
|
76
77
|
- spec/multi_key_hash_spec.rb
|
77
78
|
- spec/spec_helper.rb
|
78
|
-
homepage:
|
79
|
+
homepage: https://github.com/SamirHodzic/multi_key_hash
|
79
80
|
licenses:
|
80
81
|
- MIT
|
81
82
|
metadata: {}
|
@@ -98,7 +99,7 @@ rubyforge_project:
|
|
98
99
|
rubygems_version: 2.6.13
|
99
100
|
signing_key:
|
100
101
|
specification_version: 4
|
101
|
-
summary:
|
102
|
+
summary: MultiKeyHash gem for ruby
|
102
103
|
test_files:
|
103
104
|
- spec/multi_key_hash_spec.rb
|
104
105
|
- spec/spec_helper.rb
|