to-hash 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +18 -0
  4. data/lib/to-hash.rb +10 -0
  5. data/lib/version.rb +1 -0
  6. metadata +48 -0
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 93b54295a8d21d636ea3052a3c649f7f30ca317e
4
+ data.tar.gz: 65f634ab31a7b95923b2609295594d222d0fd0ae
5
+ SHA512:
6
+ metadata.gz: 89b73424ed32ce6a4006543049860231d3f1d80291570ff8601ec81ebd74fb27557dd02dc88c7077cff18cc84a492ed1b0c9b68793dac362b287100b0365fc56
7
+ data.tar.gz: 9f62c735f48e9c95b57b91e0964856ea8297ba3ce6e216f9a4de6902471468aec296eca87a98fe9fb9d2a684f0aa2f5f7e4f0192279714c23f6f01d697d2d98c
@@ -0,0 +1,20 @@
1
+ Copyright 2012 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,18 @@
1
+ Adds a to_hash method to arrays to easily convert them to hash.
2
+
3
+ Example:
4
+
5
+ 2.0.0p247 :001 > [].to_hash
6
+ => {}
7
+ 2.0.0p247 :002 > [1].to_hash
8
+ => {1=>nil}
9
+ 2.0.0p247 :003 > [1,2].to_hash
10
+ => {1=>2}
11
+ 2.0.0p247 :004 > [1,2,3,4].to_hash
12
+ => {1=>2, 3=>4}
13
+ 2.0.0p247 :005 > [[1,2],[3,4]].to_hash
14
+ => {1=>2, 3=>4}
15
+
16
+
17
+
18
+
@@ -0,0 +1,10 @@
1
+ class Array
2
+ def to_hash
3
+ hash = {}
4
+ self.flatten(1).each_slice(2) do |k, v|
5
+ hash[k] = v
6
+ end
7
+
8
+ hash
9
+ end
10
+ end
@@ -0,0 +1 @@
1
+ VERSION = "0.0.1"
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: to-hash
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sujoy Gupta
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-02 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Adds a to_hash method to arrays.
14
+ email:
15
+ - sujoyg@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/to-hash.rb
21
+ - lib/version.rb
22
+ - MIT-LICENSE
23
+ - README.rdoc
24
+ homepage: http://www.github.com/sujoyg/to_hash
25
+ licenses:
26
+ - MIT
27
+ metadata: {}
28
+ post_install_message:
29
+ rdoc_options: []
30
+ require_paths:
31
+ - lib
32
+ required_ruby_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - '>='
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ required_rubygems_version: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '>='
40
+ - !ruby/object:Gem::Version
41
+ version: '0'
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 2.1.4
45
+ signing_key:
46
+ specification_version: 4
47
+ summary: to_hash method for arrays.
48
+ test_files: []