Class: UserNotificationScheduleProcessor

Inherits:
Object
  • Object
show all
Defined in:
app/services/user_notification_schedule_processor.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(schedule) ⇒ UserNotificationScheduleProcessor

Returns a new instance of UserNotificationScheduleProcessor.



6
7
8
9
10
# File 'app/services/user_notification_schedule_processor.rb', line 6

def initialize(schedule)
  @schedule = schedule
  @user = schedule.user
  @timezone_name = user.user_option.timezone
end

Instance Attribute Details

#scheduleObject

Returns the value of attribute schedule.



4
5
6
# File 'app/services/user_notification_schedule_processor.rb', line 4

def schedule
  @schedule
end

#timezone_nameObject

Returns the value of attribute timezone_name.



4
5
6
# File 'app/services/user_notification_schedule_processor.rb', line 4

def timezone_name
  @timezone_name
end

#userObject

Returns the value of attribute user.



4
5
6
# File 'app/services/user_notification_schedule_processor.rb', line 4

def user
  @user
end

Class Method Details

.create_do_not_disturb_timings_for(schedule) ⇒ Object



18
19
20
21
# File 'app/services/user_notification_schedule_processor.rb', line 18

def self.create_do_not_disturb_timings_for(schedule)
  processor = UserNotificationScheduleProcessor.new(schedule)
  processor.create_do_not_disturb_timings
end

Instance Method Details

#create_do_not_disturb_timingsObject



12
13
14
15
16
# File 'app/services/user_notification_schedule_processor.rb', line 12

def create_do_not_disturb_timings
  local_time = Time.now.in_time_zone(timezone_name)

  create_timings_for(local_time, days: 2)
end