Class: Dorsale::Flyboy::Task::Snoozer

Inherits:
Service
  • Object
show all
Defined in:
app/services/dorsale/flyboy/task/snoozer.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Service

call

Constructor Details

#initialize(task) ⇒ Snoozer

Returns a new instance of Snoozer.



4
5
6
7
# File 'app/services/dorsale/flyboy/task/snoozer.rb', line 4

def initialize(task)
  super()
  @task = task
end

Instance Attribute Details

#taskObject (readonly)

Returns the value of attribute task.



2
3
4
# File 'app/services/dorsale/flyboy/task/snoozer.rb', line 2

def task
  @task
end

Instance Method Details

#callObject



9
10
11
# File 'app/services/dorsale/flyboy/task/snoozer.rb', line 9

def call
  snooze
end

#snoozable?Boolean

Returns:

  • (Boolean)


25
26
27
28
29
30
31
32
33
34
35
# File 'app/services/dorsale/flyboy/task/snoozer.rb', line 25

def snoozable?
  if task.done?
    false
  elsif task.reminder_date
    task.reminder_date <= current_date
  elsif task.term
    task.term <= current_date
  else # rubocop:disable Lint/DuplicateBranch
    false
  end
end

#snoozeObject



13
14
15
16
17
18
19
20
21
22
23
# File 'app/services/dorsale/flyboy/task/snoozer.rb', line 13

def snooze
  if task.term
    task.term = task.term + snooze_term_value
  end

  if task.reminder_type == "custom"
    task.reminder_date = task.reminder_date + snooze_reminder_value
  end

  return task.save
end