Sha256: f7ee4693eceea4b098f033d8880cb43d0c22aa04c8c8f04fd214c79558068d71

Contents?: true

Size: 692 Bytes

Versions: 19

Compression:

Stored size: 692 Bytes

Contents

# frozen_string_literal: true

require 'eac_ruby_utils/core_ext'

module EhbrsRubyUtils
  class CircularListSpreader
    module BaseLevel
      extend ::Comparable

      def <=>(other)
        s = remaining_f <=> other.remaining_f
        return s unless s.zero?

        s = total_i <=> other.total_i
        return s unless s.zero?

        label <=> other.label
      end

      def remaining?
        remaining_i.positive?
      end

      def remaining_f
        remaining_i.to_f / total_i
      end

      def remaining_fs
        ((remaining_f * 1000).round / 10.0).to_s + '%'
      end

      def debugs
        [label, remaining_fs, total_i].join(' / ')
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
ehbrs_ruby_utils-0.33.0 lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
ehbrs_ruby_utils-0.32.0 lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
ehbrs_ruby_utils-0.31.0 lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
ehbrs_ruby_utils-0.30.0 lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
ehbrs_ruby_utils-0.29.0 lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
ehbrs_ruby_utils-0.28.0 lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
ehbrs_ruby_utils-0.27.1 lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
ehbrs_ruby_utils-0.27.0 lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
ehbrs_ruby_utils-0.26.0 lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
ehbrs_ruby_utils-0.25.1 lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
ehbrs_ruby_utils-0.25.0 lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
ehbrs_ruby_utils-0.24.1 lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
ehbrs_ruby_utils-0.24.0 lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
ehbrs_ruby_utils-0.23.0 lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
ehbrs_ruby_utils-0.22.0 lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
ehbrs_ruby_utils-0.21.0 lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
ehbrs_ruby_utils-0.20.0 lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
ehbrs_ruby_utils-0.19.0 lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb
ehbrs_ruby_utils-0.18.0 lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb