class Checkups::IntervalChecker

Public Class Methods

is_hour_at_day_interval?(daily_frequency, time = Time.now.utc) click to toggle source

rubocop:disable Naming/PredicateName

# File lib/checkups/notification_timer.rb, line 28
def self.is_hour_at_day_interval?(daily_frequency, time = Time.now.utc)
  frequency = word_to_number(daily_frequency) || 1
  hourly_interval = 24 / frequency
  time.utc.hour.divmod(hourly_interval)[1].zero?
end
word_to_number(word) click to toggle source

rubocop:enable Naming/PredicateName

# File lib/checkups/notification_timer.rb, line 35
def self.word_to_number(word)
  case word
  when String
    {
      "two" => 2,
      "three" => 3,
      "four" => 4,
      "six" => 6,
      "eight" => 8,
    }[word]
  else
    word
  end
end