utilities 0.0.22 → 0.0.23

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.
data/README.md CHANGED
@@ -29,7 +29,7 @@ Usage
29
29
 
30
30
  [1,2,3].map_with([4,5,6]){|i,j| i * j } #=> [4,10,18]
31
31
 
32
- * warp
32
+ * wrap
33
33
 
34
34
  [1, 2, 3].wrap("*") #=> ["*1*", "*2*", "*3*"]
35
35
  [1, 2, 3].wrap("*", "+") #=> ["*1+", "*2+", "*3+"]
@@ -98,6 +98,14 @@ Usage
98
98
  nil.attempt(:something) #=> nil
99
99
  "String".attempt(:wrong_method_name) #=> nil
100
100
 
101
+ * is_any?
102
+
103
+ Returns true if object is one of the passed classes
104
+
105
+ {}.is_any?(Array, Hash, Class) #=> true
106
+ "".is_any?(Array) #=> false
107
+
108
+
101
109
  #### String
102
110
  * hour_to_float
103
111
 
@@ -15,4 +15,10 @@ class Object
15
15
  nil
16
16
  end
17
17
  end
18
+
19
+ def is_any?(*args)
20
+ args.any? do |klass|
21
+ self.is_a? klass
22
+ end
23
+ end
18
24
  end
@@ -1,7 +1,7 @@
1
1
  module Utilities
2
2
  MAJOR = 0
3
3
  MINOR = 0
4
- BUILD = 22
4
+ BUILD = 23
5
5
 
6
6
  VERSION = "#{MAJOR}.#{MINOR}.#{BUILD}"
7
7
  end
@@ -199,3 +199,12 @@ describe Utilities::Statistics do
199
199
  }
200
200
  end
201
201
  end
202
+
203
+ describe Object do
204
+ it "#is_any? should return true if object is in the classes and false otherwise" do
205
+ {:a => :b}.is_any?(Hash, Class).should be_true
206
+ [].is_any?(Hash, Class).should be_false
207
+ [].is_any?(Array).should be_true
208
+ "".is_any?(Array).should be_false
209
+ end
210
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: utilities
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.22
4
+ version: 0.0.23
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -11,8 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2011-10-17 00:00:00.000000000 -04:00
15
- default_executable:
14
+ date: 2012-03-01 00:00:00.000000000 Z
16
15
  dependencies: []
17
16
  description: Few utilities include in all my projects, including a module for statistics,
18
17
  some to_date and to_time functions as well as intersection method for Range object.
@@ -40,7 +39,6 @@ files:
40
39
  - lib/version.rb
41
40
  - test/test_utilities.rb
42
41
  - utilities.gemspec
43
- has_rdoc: true
44
42
  homepage: http://github.com/christianblais/utilities
45
43
  licenses: []
46
44
  post_install_message:
@@ -62,7 +60,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
62
60
  version: '0'
63
61
  requirements: []
64
62
  rubyforge_project:
65
- rubygems_version: 1.6.2
63
+ rubygems_version: 1.8.15
66
64
  signing_key:
67
65
  specification_version: 3
68
66
  summary: Few utilities include in all my projects