Module: EventInstanceMethods

Included in:
Event, EventRevision
Defined in:
app/models/event_instance_methods.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#end_dateObject

Returns the value of attribute end_date.



2
3
4
# File 'app/models/event_instance_methods.rb', line 2

def end_date
  @end_date
end

#end_timeObject

Returns the value of attribute end_time.



2
3
4
# File 'app/models/event_instance_methods.rb', line 2

def end_time
  @end_time
end

#start_dateObject

Returns the value of attribute start_date.



2
3
4
# File 'app/models/event_instance_methods.rb', line 2

def start_date
  @start_date
end

#start_timeObject

Returns the value of attribute start_time.



2
3
4
# File 'app/models/event_instance_methods.rb', line 2

def start_time
  @start_time
end

Instance Method Details

#dateObject



67
68
69
# File 'app/models/event_instance_methods.rb', line 67

def date
  one_day? ? one_day_date : multi_day_date
end

#end_dayObject



56
57
58
# File 'app/models/event_instance_methods.rb', line 56

def end_day
  end_on.present? ? end_on.in_time_zone(timezone).day : end_on
end

#end_hourObject



48
49
50
# File 'app/models/event_instance_methods.rb', line 48

def end_hour
  end_on.present? ? end_on.hour : end_on
end

#end_minObject



52
53
54
# File 'app/models/event_instance_methods.rb', line 52

def end_min
  end_on.present? ? end_on.min : end_on
end

#end_monthObject



44
45
46
# File 'app/models/event_instance_methods.rb', line 44

def end_month
  end_on.present? ? end_on.in_time_zone(timezone).strftime("%B") : end_on
end

#end_yearObject



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

def end_year
  end_on.present? ? end_on.year : end_on
end

#multi_day_dateObject



75
76
77
78
79
# File 'app/models/event_instance_methods.rb', line 75

def multi_day_date
  return one_day_date if end_on.blank?
  "#{start_on.in_time_zone(timezone).strftime('%A, %B %d')} - "+
  "#{end_on.in_time_zone(timezone).strftime('%A, %B %d %Y')}"
end

#one_day?Boolean

Returns:

  • (Boolean)


60
61
62
63
64
65
# File 'app/models/event_instance_methods.rb', line 60

def one_day?
  return true if start_on.blank? || end_on.blank?
  start_on.day == end_on.day &&
  start_on.month== end_on.month &&
  start_on.year == end_on.year
end

#one_day_dateObject



71
72
73
# File 'app/models/event_instance_methods.rb', line 71

def one_day_date
  start_on.in_time_zone(timezone).strftime('%A, %B %d %Y')
end

#start_dayObject



28
29
30
# File 'app/models/event_instance_methods.rb', line 28

def start_day
  start_on.present? ? start_on.in_time_zone(timezone).day : start_on
end

#start_hourObject



32
33
34
# File 'app/models/event_instance_methods.rb', line 32

def start_hour
  start_on.present? ? start_on.hour : start_on
end

#start_minObject



36
37
38
# File 'app/models/event_instance_methods.rb', line 36

def start_min
  start_on.present? ? start_on.min : start_on
end

#start_monthObject



24
25
26
# File 'app/models/event_instance_methods.rb', line 24

def start_month
  start_on.present? ? start_on.in_time_zone(timezone).strftime("%B") : start_on
end

#start_yearObject



20
21
22
# File 'app/models/event_instance_methods.rb', line 20

def start_year
  start_on.present? ? start_on.in_time_zone(timezone).year : start_on
end