Class: FistOfFury::Schedule

Inherits:
Object
  • Object
show all
Defined in:
lib/fist_of_fury/schedule.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeSchedule

Returns a new instance of Schedule.



5
6
7
8
# File 'lib/fist_of_fury/schedule.rb', line 5

def initialize
  start_time = FistOfFury.config.utc ? Time.now.utc : Time.now
  self.ice_cube_schedule = IceCube::Schedule.new(start_time)
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fist_of_fury/schedule.rb', line 10

def method_missing(meth, *args, &block)
  if IceCube::Rule.respond_to?(meth)
    rule = IceCube::Rule.send(meth, *args, &block)
    ice_cube_schedule.add_recurrence_rule(rule)
    rule
  elsif ice_cube_schedule.respond_to?(meth)
    ice_cube_schedule.send(meth, *args, &block)
  else
    super
  end
end

Instance Attribute Details

#ice_cube_scheduleObject

Returns the value of attribute ice_cube_schedule.



3
4
5
# File 'lib/fist_of_fury/schedule.rb', line 3

def ice_cube_schedule
  @ice_cube_schedule
end

#last_occurrenceObject

Returns the value of attribute last_occurrence.



3
4
5
# File 'lib/fist_of_fury/schedule.rb', line 3

def last_occurrence
  @last_occurrence
end

#optionsObject

Returns the value of attribute options.



3
4
5
# File 'lib/fist_of_fury/schedule.rb', line 3

def options
  @options
end

Instance Method Details

#scheduled_time_met?(time) ⇒ Boolean

Returns:

  • (Boolean)


22
23
24
25
26
27
# File 'lib/fist_of_fury/schedule.rb', line 22

def scheduled_time_met?(time)
  self.last_occurrence = next_occurrence(time) unless last_occurrence
  return false if last_occurrence_is_next_occurrence?(time)
  self.last_occurrence = next_occurrence(time)
  true
end

#to_sObject



29
30
31
# File 'lib/fist_of_fury/schedule.rb', line 29

def to_s
  ice_cube_schedule.to_s
end