Module: Equatable::Methods

Defined in:
lib/equatable.rb

Instance Method Summary collapse

Instance Method Details

#==(other) ⇒ Boolean

Compare two objects for equality based on their value and being a subclass of the given class.

Parameters:

  • other (Object)

    the other object in comparison

Returns:

  • (Boolean)


145
146
147
148
# File 'lib/equatable.rb', line 145

def ==(other)
  return false unless self.class <=> other.class
  compare?(__method__, other)
end

#eql?(other) ⇒ Boolean

Compare two objects for equality based on their value and being an instance of the given class.

Parameters:

  • other (Object)

    the other object in comparison

Returns:

  • (Boolean)


132
133
134
# File 'lib/equatable.rb', line 132

def eql?(other)
  instance_of?(other.class) and compare?(__method__, other)
end