lib/sidekiq/throttled/web/stats.rb in sidekiq-throttled-0.8.2 vs lib/sidekiq/throttled/web/stats.rb in sidekiq-throttled-0.9.0
- old
+ new
@@ -12,13 +12,14 @@
[1, "second", "seconds"]
].freeze
# @param [Strategy::Concurrency, Strategy::Threshold] strategy
def initialize(strategy)
- if strategy && strategy.dynamic?
+ if strategy&.dynamic?
raise ArgumentError, "Can't handle dynamic strategies"
end
+
@strategy = strategy
end
# @return [String]
def to_html
@@ -50,11 +51,13 @@
def humanize_duration(int)
arr = []
TIME_CONVERSION.each do |(dimension, unit, units)|
count = (int / dimension).to_i
- next unless 0 < count
+
+ next unless count.positive?
+
int -= count * dimension
arr << "#{count} #{1 == count ? unit : units}"
end
arr.join " "
@@ -63,10 +66,10 @@
# @return [String]
def humanize_integer(int)
digits = int.to_s.split ""
str = digits.shift(digits.count % 3).join("")
- str << " " << digits.shift(3).join("") while 0 < digits.count
+ str << " " << digits.shift(3).join("") while digits.count.positive?
str.strip
end
end
end