is_same 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/is_same/core_ext.rb +15 -7
  2. metadata +9 -9
@@ -12,7 +12,7 @@ class Class
12
12
  when Symbol
13
13
  object == self.name.to_sym
14
14
  when Regexp
15
- !!object.match(self.name)
15
+ !!object.match( self.name )
16
16
  else
17
17
  super
18
18
  end
@@ -27,7 +27,7 @@ class Numeric
27
27
  when Symbol
28
28
  object == self.to_s.to_sym
29
29
  when Regexp
30
- !!object.match(self.to_s)
30
+ !!object.match( self.to_s )
31
31
  else
32
32
  super
33
33
  end
@@ -38,9 +38,9 @@ class Regexp
38
38
  def is_same? object
39
39
  case object
40
40
  when Class
41
- !!self.match(object.name)
41
+ !!self.match( object.name )
42
42
  when Numeric, String, Symbol
43
- !!self.match(object.to_s)
43
+ !!self.match( object.to_s )
44
44
  else
45
45
  super
46
46
  end
@@ -55,7 +55,7 @@ class String
55
55
  when Numeric, Symbol
56
56
  self == object.to_s
57
57
  when Regexp
58
- !!object.match(self)
58
+ !!object.match( self )
59
59
  else
60
60
  super
61
61
  end
@@ -70,7 +70,7 @@ class Symbol
70
70
  when Numeric
71
71
  self == object.to_s.to_sym
72
72
  when Regexp
73
- !!object.match(self.to_s)
73
+ !!object.match( self.to_s )
74
74
  when String
75
75
  self == object.to_sym
76
76
  else
@@ -81,7 +81,7 @@ class Symbol
81
81
  end
82
82
 
83
83
  class Array
84
- # Check if any elements of an Array is same as argument
84
+ # Check if any elements of an Array is same as argument.
85
85
  #
86
86
  # @param Object
87
87
  # @return Boolean
@@ -96,4 +96,12 @@ class Array
96
96
  include_same
97
97
  end
98
98
 
99
+ # Return Array elements that include same.
100
+ #
101
+ # @param Object
102
+ # @return Array<Object> Matching objects.
103
+ def including_same object
104
+ self.select {|value| value.is_same? object }
105
+ end
106
+
99
107
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: is_same
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-02-20 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rspec
16
- requirement: &22119300 !ruby/object:Gem::Requirement
16
+ requirement: &15653580 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *22119300
24
+ version_requirements: *15653580
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec-core
27
- requirement: &22118840 !ruby/object:Gem::Requirement
27
+ requirement: &15653120 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *22118840
35
+ version_requirements: *15653120
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: yard
38
- requirement: &22118420 !ruby/object:Gem::Requirement
38
+ requirement: &15652700 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *22118420
46
+ version_requirements: *15652700
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: yard-rdoc
49
- requirement: &22118000 !ruby/object:Gem::Requirement
49
+ requirement: &15652280 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *22118000
57
+ version_requirements: *15652280
58
58
  description: To evaluate if different kind of objects have the same value or meaning,
59
59
  comparing objects without the need to worry about their type. Supports regexp.
60
60
  email: margus@tione.eu