Class: Object

Inherits:
BasicObject
Defined in:
lib/object-in-enumerable.rb

Instance Method Summary collapse

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.

Returns:

  • (Boolean)


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

Returns:

  • (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