Class: Object
- Inherits:
- BasicObject
- Defined in:
- lib/object-in-enumerable.rb
Instance Method Summary collapse
-
#in?(enum) ⇒ Boolean
Uses the given enum’s include? method to determine whether the object is included in it.
- #not_in?(enum) ⇒ Boolean
Instance Method Details
#in?(enum) ⇒ Boolean
Uses the given enum’s include? method to determine whether the object is included in it. If the given method doesn’t respond to include?, returns nil.
3 4 5 |
# File 'lib/object-in-enumerable.rb', line 3 def in?(enum) enum.respond_to?(:include?) ? enum.include?(self) : nil end |
#not_in?(enum) ⇒ Boolean
7 8 9 |
# File 'lib/object-in-enumerable.rb', line 7 def not_in?(enum) enum.respond_to?(:include?) ? !enum.include?(self) : nil end |