Sha256: 8a4442a471121e24deaea070994a891eba7cf2f46b5ee1cf3a499e9dd047fdcf

Contents?: true

Size: 493 Bytes

Versions: 6

Compression:

Stored size: 493 Bytes

Contents

# frozen_string_literal: true

module Vnstat
  class Result
    ##
    # A module that is included by result types that can be compared based
    # on their particular time information.
    module TimeComparable
      ##
      # @return [Integer, nil]
      def <=>(other)
        return nil unless other.respond_to?(:bytes_transmitted)
        return nil unless other.respond_to?(:time)

        [time, bytes_transmitted] <=> [other.time, other.bytes_transmitted]
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
vnstat-ruby-3.0.7 lib/vnstat/result/time_comparable.rb
vnstat-ruby-3.0.6 lib/vnstat/result/time_comparable.rb
vnstat-ruby-3.0.5 lib/vnstat/result/time_comparable.rb
vnstat-ruby-3.0.4 lib/vnstat/result/time_comparable.rb
vnstat-ruby-3.0.2 lib/vnstat/result/time_comparable.rb
vnstat-ruby-3.0.0 lib/vnstat/result/time_comparable.rb