Class: IceCube::HourlyRule

Inherits:
Rule
  • Object
show all
Defined in:
lib/ice_cube/rules/hourly_rule.rb

Instance Attribute Summary

Attributes inherited from Rule

#occurrence_count, #until_date, #validations

Instance Method Summary collapse

Methods inherited from Rule

#count, daily, from_hash, from_yaml, hourly, minutely, monthly, #next_suggestion, secondly, #to_hash, #to_yaml, #until, #validate_single_date, weekly, yearly

Methods included from ValidationTypes

#day, #day_of_month, #day_of_week, #day_of_year, #hour_of_day, #minute_of_hour, #month_of_year, #second_of_minute

Instance Method Details

#in_interval?(date, start_date) ⇒ Boolean

Determine whether this rule occurs on a give date.

Returns:

  • (Boolean)


6
7
8
9
10
# File 'lib/ice_cube/rules/hourly_rule.rb', line 6

def in_interval?(date, start_date)
  #make sure we're in a proper interval
  day_count = ((date - start_date) / IceCube::ONE_HOUR).to_i
  day_count % @interval == 0
end

#to_icalObject



12
13
14
# File 'lib/ice_cube/rules/hourly_rule.rb', line 12

def to_ical 
  'FREQ=HOURLY' << to_ical_base
end

#to_sObject



16
17
18
# File 'lib/ice_cube/rules/hourly_rule.rb', line 16

def to_s
  to_s_base 'Hourly', "Every #{@interval} hours"
end