Module: EhbrsRubyUtils::CircularListSpreader::BaseLevel

Extended by:
Comparable
Included in:
GroupLevel, ItemLevel
Defined in:
lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb

Instance Method Summary collapse

Instance Method Details

#<=>(other) ⇒ Object



10
11
12
13
14
15
16
17
18
# File 'lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb', line 10

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

#debugsObject



32
33
34
# File 'lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb', line 32

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

#remaining?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb', line 20

def remaining?
  remaining_i.positive?
end

#remaining_fObject



24
25
26
# File 'lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb', line 24

def remaining_f
  remaining_i.to_f / total_i
end

#remaining_fsObject



28
29
30
# File 'lib/ehbrs_ruby_utils/circular_list_spreader/base_level.rb', line 28

def remaining_fs
  "#{(remaining_f * 1000).round / 10.0}%"
end