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
# File 'lib/fist_of_fury/schedule.rb', line 5

def initialize
  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



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

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

#schedule_next(time) ⇒ Object



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

def schedule_next(time)
  return unless schedule_next?(time)
  self.last_occurrence = next_occurrence(time)
  yield
end

#start_timeObject



31
32
33
# File 'lib/fist_of_fury/schedule.rb', line 31

def start_time
  @start_time ||= FistOfFury.config.utc ? Time.utc(2010, 1, 1) : Time.local(2010, 1, 1)
end

#to_sObject



27
28
29
# File 'lib/fist_of_fury/schedule.rb', line 27

def to_s
  ice_cube_schedule.to_s
end