hash-utils 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.0
1
+ 0.3.1
data/hash-utils.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{hash-utils}
8
- s.version = "0.3.0"
8
+ s.version = "0.3.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Martin Kozák"]
12
- s.date = %q{2011-01-12}
12
+ s.date = %q{2011-01-20}
13
13
  s.email = %q{martinkozak@martinkozak.net}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE.txt",
@@ -1,6 +1,10 @@
1
1
  # encoding: utf-8
2
2
  # (c) 2011 Martin Kozák (martinkozak@martinkozak.net)
3
3
 
4
+ ##
5
+ # Array extension.
6
+ #
7
+
4
8
  class Array
5
9
 
6
10
  ##
@@ -9,6 +13,10 @@ class Array
9
13
  # Works similar to #reject!, but returns removed items instead
10
14
  # of remaining items.
11
15
  #
16
+ # @param [Proc] block selecting block
17
+ # @return [Array] removed values
18
+ # @since 0.3.0
19
+ #
12
20
 
13
21
  def remove!(&block)
14
22
  result = [ ]
@@ -30,6 +38,10 @@ class Array
30
38
  #
31
39
  # If it's empty, returns <tt>true</tt>.
32
40
  #
41
+ # @param [Proc] block checking block
42
+ # @return [Boolean] 'true' if yes, 'false' in otherwise
43
+ # @since 0.2.0
44
+ #
33
45
 
34
46
  def all?(&block)
35
47
  if self.empty?
@@ -49,6 +61,10 @@ class Array
49
61
  # Checks, at least one value follows condition expressed in
50
62
  # block. Block must return Boolean.
51
63
  #
64
+ # @param [Proc] block checking block
65
+ # @return [Boolean] 'true' if yes, 'false' in otherwise
66
+ # @since 0.2.0
67
+ #
52
68
 
53
69
  def some?(&block)
54
70
  self.each do |v|
@@ -1,11 +1,22 @@
1
1
  # encoding: utf-8
2
2
  # (c) 2011 Martin Kozák (martinkozak@martinkozak.net)
3
3
 
4
+
5
+ ##
6
+ # Hash extension.
7
+ #
8
+
4
9
  class Hash
5
10
 
6
11
  ##
7
12
  # Defines hash by setting the default value or Proc and content.
8
13
  #
14
+ # @param [Hash] values initial values
15
+ # @param [Object] default default value
16
+ # @param [Proc] block default block
17
+ # @return [Hash] new hash
18
+ # @since 0.3.0
19
+ #
9
20
 
10
21
  def self.define(values = { }, default = nil, &block)
11
22
  hash = self[values]
@@ -15,6 +26,12 @@ class Hash
15
26
  ##
16
27
  # Creates hash by setting default settings in one call.
17
28
  #
29
+ # @param [Hash] values initial values
30
+ # @param [Object] default default value
31
+ # @param [Proc] block default block
32
+ # @return [Hash] new hash
33
+ # @since 0.3.0
34
+ #
18
35
 
19
36
  def self.create(default = nil, hash = { }, &block)
20
37
  hash.default = default
@@ -30,6 +47,9 @@ class Hash
30
47
  # Recreates the hash, so creates empty one and assigns
31
48
  # the same default values.
32
49
  #
50
+ # @return [Hash] new hash
51
+ # @since 0.3.0
52
+ #
33
53
 
34
54
  def recreate
35
55
  self.class::create(self.default, &self.default_proc)
@@ -39,6 +59,8 @@ class Hash
39
59
  # Recreates the hash in place, so creates empty one, assigns
40
60
  # the same default values and replaces the old one.
41
61
  #
62
+ # @since 0.3.0
63
+ #
42
64
 
43
65
  def recreate!
44
66
  self.replace(self.recreate)
@@ -48,6 +70,10 @@ class Hash
48
70
  # Moves selected pairs outside the hash, so returns them.
49
71
  # Output hash has the same default settings.
50
72
  #
73
+ # @param [Proc] block selecting block
74
+ # @return [Hash] removed selected pairs
75
+ # @since 0.3.0
76
+ #
51
77
 
52
78
  def remove!(&block)
53
79
  result = self.recreate
@@ -71,6 +97,9 @@ class Hash
71
97
  # Returns a copy of <tt>self</tt> with all <tt>nil</tt>
72
98
  # elements removed.
73
99
  #
100
+ # @return [Hash] new hash
101
+ # @since 0.1.0
102
+ #
74
103
 
75
104
  def compact
76
105
  self.reject { |k, v| v.nil? }
@@ -78,7 +107,10 @@ class Hash
78
107
 
79
108
  ##
80
109
  # Removes <tt>nil</tt> elements from the hash. Returns <tt>nil</tt>
81
- # if no changes were made, otherwise returns <tt>self</self>.
110
+ # if no changes were made, otherwise returns <tt>self</tt>.
111
+ #
112
+ # @return [Hash] new hash
113
+ # @since 0.1.0
82
114
  #
83
115
 
84
116
  def compact!
@@ -88,6 +120,10 @@ class Hash
88
120
  ##
89
121
  # Returns a new hash with the results of running block once for
90
122
  # every pair in <tt>self</tt>.
123
+ #
124
+ # @param [Proc] block evaluating block
125
+ # @return [Hash] new hash
126
+ # @since 0.1.0
91
127
  #
92
128
 
93
129
  def map_pairs(&block)
@@ -107,6 +143,9 @@ class Hash
107
143
  # Emulates #map_pairs on place. In fact, replaces old hash by
108
144
  # new one.
109
145
  #
146
+ # @param [Proc] block evaluating block
147
+ # @since 0.1.0
148
+ #
110
149
 
111
150
  def map_pairs!(&block)
112
151
  self.replace(self.map_pairs(&block))
@@ -118,6 +157,10 @@ class Hash
118
157
  # Returns a new hash with the results of running block once for
119
158
  # every key in <tt>self</tt>.
120
159
  #
160
+ # @param [Proc] block evaluating block
161
+ # @return [Hash] new hash
162
+ # @since 0.1.0
163
+ #
121
164
 
122
165
  def map_keys(&block)
123
166
  self.map_pairs do |k, v|
@@ -131,6 +174,9 @@ class Hash
131
174
  # Emulates #map_keys on place. In fact, replaces old hash by
132
175
  # new one.
133
176
  #
177
+ # @param [Proc] block evaluating block
178
+ # @since 0.1.0
179
+ #
134
180
 
135
181
  def map_keys!(&block)
136
182
  self.replace(self.map_keys(&block))
@@ -141,6 +187,9 @@ class Hash
141
187
  ##
142
188
  # Converts all keys to symbols.
143
189
  #
190
+ # @return [Hash] new hash
191
+ # @since 0.1.0
192
+ #
144
193
 
145
194
  def keys_to_sym
146
195
  self.map_keys { |k| k.to_sym }
@@ -150,6 +199,8 @@ class Hash
150
199
  # Emulates #keys_to_sym on place. In fact, replaces old hash by
151
200
  # new one.
152
201
  #
202
+ # @since 0.1.0
203
+ #
153
204
 
154
205
  def keys_to_sym!
155
206
  self.replace(self.keys_to_sym)
@@ -161,6 +212,10 @@ class Hash
161
212
  #
162
213
  # If it's empty, returns <tt>true</tt>.
163
214
  #
215
+ # @param [Proc] block checking block
216
+ # @return [Boolean] 'true' if yes, 'false' in otherwise
217
+ # @since 0.2.0
218
+ #
164
219
 
165
220
  def all?(&block)
166
221
  if self.empty?
@@ -182,6 +237,10 @@ class Hash
182
237
  #
183
238
  # If it's empty, returns <tt>true</tt>.
184
239
  #
240
+ # @param [Proc] block checking block
241
+ # @return [Boolean] 'true' if yes, 'false' in otherwise
242
+ # @since 0.2.0
243
+ #
185
244
 
186
245
  def all_pairs?(&block)
187
246
  if self.empty?
@@ -201,6 +260,10 @@ class Hash
201
260
  # Checks, at least one element value follows condition expressed in
202
261
  # block. Block must return Boolean.
203
262
  #
263
+ # @param [Proc] block checking block
264
+ # @return [Boolean] 'true' if yes, 'false' in otherwise
265
+ # @since 0.2.0
266
+ #
204
267
 
205
268
  def some?(&block)
206
269
  self.each_value do |v|
@@ -216,6 +279,10 @@ class Hash
216
279
  # Checks, at least one element follows condition expressed in
217
280
  # block. Block must return Boolean.
218
281
  #
282
+ # @param [Proc] block checking block
283
+ # @return [Boolean] 'true' if yes, 'false' in otherwise
284
+ # @since 0.2.0
285
+ #
219
286
 
220
287
  def some_pairs?(&block)
221
288
  self.each_pair do |k, v|
@@ -1,10 +1,18 @@
1
1
  # encoding: utf-8
2
2
  # (c) 2011 Martin Kozák (martinkozak@martinkozak.net)
3
3
 
4
+ ##
5
+ # Numeric extension.
6
+ #
7
+
4
8
  class Numeric
5
9
  ##
6
10
  # Indicates numeric is in some object which supports #include?.
7
11
  #
12
+ # @param [Object] range container for analyzing
13
+ # @param [Boolean] 'true' if yes, 'false' in otherwise
14
+ # @since 0.3.0
15
+ #
8
16
 
9
17
  def in?(range)
10
18
  range.include? self
@@ -1,6 +1,10 @@
1
1
  # encoding: utf-8
2
2
  # (c) 2011 Martin Kozák (martinkozak@martinkozak.net)
3
3
 
4
+ ##
5
+ # String extension.
6
+ #
7
+
4
8
  class String
5
9
  ##
6
10
  # Holds numeric matcher.
@@ -11,6 +15,10 @@ class String
11
15
  ##
12
16
  # Indicates string is in some object which supports #include?.
13
17
  #
18
+ # @param [Object] range container for analyzing
19
+ # @param [Boolean] 'true' if yes, 'false' in otherwise
20
+ # @since 0.3.0
21
+ #
14
22
 
15
23
  def in?(range)
16
24
  range.include? self
@@ -19,6 +27,9 @@ class String
19
27
  ##
20
28
  # Indicates, string is numeric, so consists of numbers only.
21
29
  #
30
+ # @return [Boolean] 'true' if yes, 'false' in otherwise
31
+ # @since 0.3.0
32
+ #
22
33
 
23
34
  def numeric?
24
35
  if self.match(self.class::NUMERIC)
@@ -1,10 +1,19 @@
1
1
  # encoding: utf-8
2
2
  # (c) 2011 Martin Kozák (martinkozak@martinkozak.net)
3
3
 
4
+
5
+ ##
6
+ # Symbol extension.
7
+ #
8
+
4
9
  class Symbol
5
10
  ##
6
11
  # Indicates symbol is in some object which supports #include?.
7
12
  #
13
+ # @param [Object] range container for analyzing
14
+ # @param [Boolean] 'true' if yes, 'false' in otherwise
15
+ # @since 0.3.0
16
+ #
8
17
 
9
18
  def in?(range)
10
19
  range.include? self
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 0
9
- version: 0.3.0
8
+ - 1
9
+ version: 0.3.1
10
10
  platform: ruby
11
11
  authors:
12
12
  - "Martin Koz\xC3\xA1k"
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2011-01-12 00:00:00 +01:00
17
+ date: 2011-01-20 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -85,7 +85,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - ">="
87
87
  - !ruby/object:Gem::Version
88
- hash: -3600041208124521153
88
+ hash: -3792094260852597544
89
89
  segments:
90
90
  - 0
91
91
  version: "0"