Module: IceCube::Validations::MinuteOfHour

Included in:
DailyRule, HourlyRule, MinutelyRule, MonthlyRule, SecondlyRule, WeeklyRule, YearlyRule
Defined in:
lib/ice_cube/validations/minute_of_hour.rb

Defined Under Namespace

Classes: Validation

Instance Method Summary collapse

Instance Method Details

#minute_of_hour(*minutes) ⇒ Object


5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/ice_cube/validations/minute_of_hour.rb', line 5

def minute_of_hour(*minutes)
  minutes.flatten.each do |minute|
    unless minute.is_a?(Integer)
      raise ArgumentError, "expecting Integer value for minute, got #{minute.inspect}"
    end

    verify_alignment(minute, :min, :minute_of_hour) { |error| raise error }

    validations_for(:minute_of_hour) << Validation.new(minute)
  end
  clobber_base_validations(:min)
  self
end

#realign(opening_time, start_time) ⇒ Object


19
20
21
22
23
24
25
26
# File 'lib/ice_cube/validations/minute_of_hour.rb', line 19

def realign(opening_time, start_time)
  return super unless validations[:minute_of_hour]

  first_minute = validations[:minute_of_hour].min_by(&:value)
  time = TimeUtil::TimeWrapper.new(start_time, false)
  time.min = first_minute.value
  super opening_time, time.to_time
end