Method: OpenHAB::CoreExt::Java::Time#<=>

Defined in:
lib/openhab/core_ext/java/time.rb

#<=>(other) ⇒ Integer

Compare against another time object

Parameters:

  • other (Object)

    The other time object to compare against.

Returns:

  • (Integer)

    -1, 0, +1 depending on whether ‘other` is less than, equal to, or greater than self



40
41
42
43
44
45
46
47
48
49
# File 'lib/openhab/core_ext/java/time.rb', line 40

def <=>(other)
  logger.trace { "(#{self.class}) #{self} <=> #{other} (#{other.class})" }
  if other.is_a?(self.class)
    compare_to(other)
  elsif other.respond_to?(:coerce)
    return nil unless (lhs, rhs = other.coerce(self))

    lhs <=> rhs
  end
end