Class: FullcalendarEngine::EventSeries

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/fullcalendar_engine/event_series.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commit_buttonObject

Returns the value of attribute commit_button


4
5
6
# File 'app/models/fullcalendar_engine/event_series.rb', line 4

def commit_button
  @commit_button
end

#descriptionObject

Returns the value of attribute description


4
5
6
# File 'app/models/fullcalendar_engine/event_series.rb', line 4

def description
  @description
end

#titleObject

Returns the value of attribute title


4
5
6
# File 'app/models/fullcalendar_engine/event_series.rb', line 4

def title
  @title
end

Instance Method Details

#create_events_until_end_time(end_time = RECURRING_EVENTS_UPTO) ⇒ Object


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'app/models/fullcalendar_engine/event_series.rb', line 12

def create_events_until_end_time(end_time=RECURRING_EVENTS_UPTO)
  old_start_time   = starttime
  old_end_time     = endtime
  frequency_period = recurring_period(period)
  new_start_time, new_end_time = old_start_time, old_end_time

  while frequency.send(frequency_period).from_now(old_start_time) <= end_time
    self.events.create( 
                        :title => title, 
                        :description => description, 
                        :all_day => all_day, 
                        :starttime => new_start_time, 
                        :endtime => new_end_time
                      )
    new_start_time = old_start_time = frequency.send(frequency_period).from_now(old_start_time)
    new_end_time   = old_end_time   = frequency.send(frequency_period).from_now(old_end_time)

    if period.downcase == 'monthly' or period.downcase == 'yearly'
      begin 
        new_start_time = make_date_time(starttime, old_start_time)
        new_end_time   = make_date_time(endtime, old_end_time)
      rescue
        new_start_time = new_end_time = nil
      end
    end
  end
end

#recurring_period(period) ⇒ Object


40
41
42
# File 'app/models/fullcalendar_engine/event_series.rb', line 40

def recurring_period(period)
  Event::REPEATS.key(period.titleize).to_s.downcase
end