Class: IceCube::Rule

Inherits:
Object
  • Object
show all
Defined in:
lib/recurrent/ice_cube_extensions.rb

Instance Method Summary collapse

Instance Method Details

#==(another_rule) ⇒ Object



4
5
6
7
8
# File 'lib/recurrent/ice_cube_extensions.rb', line 4

def ==(another_rule)
  ['@interval', '@validation_types', '@validations'].all? do |variable|
    self.instance_variable_get(variable) == another_rule.instance_variable_get(variable)
  end && self.class.name == another_rule.class.name
end

#frequency_in_secondsObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/recurrent/ice_cube_extensions.rb', line 10

def frequency_in_seconds
  rule_type = self.class
  if rule_type == IceCube::YearlyRule
    @interval.years
  elsif rule_type == IceCube::MonthlyRule
    @interval.months
  elsif rule_type == IceCube::WeeklyRule
    @interval.weeks
  elsif rule_type == IceCube::DailyRule
    @interval.days
  elsif rule_type == IceCube::HourlyRule
    @interval.hours
  elsif rule_type == IceCube::MinutelyRule
    @interval.minutes
  elsif rule_type == IceCube::SecondlyRule
    @interval.seconds
  end
end