flex_core 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/flex_core.rb +64 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 5e53fdfb78093e091a095d9fe6dfdfa3d3bd42b5
4
+ data.tar.gz: a6f016f4b547c54be809c88e006f6e785d553ae0
5
+ SHA512:
6
+ metadata.gz: 37021cfbac33acd3067752ace600ab58663a260b4afbbe795c1cb0247d3ffab68c80836e183de8f4886b922ff00f6dca434684d1166d020b035a2ac9b0b4125e
7
+ data.tar.gz: 77eb21f19cb1d89e0806a8807e75f8344ee78d076811a1b1067d6bb2b5c3c3d29eecdd52b78393a34dfede80398ab21e75fd5ce990ea05991b461749bbe2ed01
data/lib/flex_core.rb ADDED
@@ -0,0 +1,64 @@
1
+ class Hash
2
+
3
+ def store! (key, value)
4
+ self.store(key, value)
5
+ self
6
+ end
7
+
8
+ def delete! (*keys)
9
+ keys.each { |k|
10
+ self.delete(k)
11
+ }
12
+ self
13
+ end
14
+
15
+ def find_add! (key, increment = 1)
16
+ if self[key].nil?
17
+ self.store(key, increment)
18
+ else
19
+ self[key] = self[key].to_i + increment
20
+ end
21
+ self
22
+ end
23
+
24
+ def find_store! (key, object)
25
+ if self[object[key]].nil?
26
+ self[object[key]] = [object]
27
+ else
28
+ self[object[key]].push(object)
29
+ end
30
+ self
31
+ end
32
+
33
+ def keep (*keys)
34
+ output = {}
35
+ keys.each { |k|
36
+ output[k] = self[k]
37
+ }
38
+ output
39
+ end
40
+
41
+ def trim_off (*keys)
42
+ output = self.dup
43
+ keys.each { |k|
44
+ output.delete(k)
45
+ }
46
+ output
47
+ end
48
+
49
+ end
50
+
51
+ class NilClass
52
+
53
+ def [] number
54
+ self
55
+ end
56
+
57
+ end
58
+
59
+ class Object
60
+ def deep_copy
61
+ Marshal.load(Marshal.dump(self))
62
+ end
63
+ end
64
+
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: flex_core
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Eugene Lai
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-03-05 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: To do
14
+ email: ejt.lai@gmail.com
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/flex_core.rb
20
+ homepage:
21
+ licenses: []
22
+ metadata: {}
23
+ post_install_message:
24
+ rdoc_options: []
25
+ require_paths:
26
+ - lib
27
+ required_ruby_version: !ruby/object:Gem::Requirement
28
+ requirements:
29
+ - - ">="
30
+ - !ruby/object:Gem::Version
31
+ version: '0'
32
+ required_rubygems_version: !ruby/object:Gem::Requirement
33
+ requirements:
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: '0'
37
+ requirements: []
38
+ rubyforge_project:
39
+ rubygems_version: 2.5.2
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: Some powerful additions to ruby core classes
43
+ test_files: []