Class: Lita::Standups::Models::StandupSchedule

Inherits:
Base
  • Object
show all
Includes:
Ohm::Callbacks, Ohm::DataTypes, Ohm::Timestamps
Defined in:
lib/lita/standups/models/standup_schedule.rb

Instance Method Summary collapse

Methods inherited from Base

redis

Instance Method Details

#cron_lineObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/lita/standups/models/standup_schedule.rb', line 20

def cron_line
  [
    time.min,
    time.hour,
    "*",
    "*",
    cron_line_week,
    "UTC"
  ].join(" ")
end

#cron_line_weekObject



31
32
33
34
35
# File 'lib/lita/standups/models/standup_schedule.rb', line 31

def cron_line_week
  return "*" if daily?
  return "1,2,3,4,5" if workdays?
  return day_of_week_index if weekly?
end

#daily?Boolean

Returns:

  • (Boolean)


56
57
58
# File 'lib/lita/standups/models/standup_schedule.rb', line 56

def daily?
  repeat == "daily"
end

#day_of_week_indexObject



37
38
39
# File 'lib/lita/standups/models/standup_schedule.rb', line 37

def day_of_week_index
  %w(sunday monday tuesday wednesday thursday friday saturday).index(day_of_week)
end

#descriptionObject



46
47
48
49
50
51
52
53
54
# File 'lib/lita/standups/models/standup_schedule.rb', line 46

def description
  [
    "ID: #{id}",
    "Standup: #{standup.name} (ID: #{standup.id})",
    "Recipients: #{recipients.join(", ")}",
    "Running #{repeat} " + (weekly? ? "on #{day_of_week} " : "") + "at #{time.strftime("%H:%M")}",
    "Sending the result on #{channel}"
  ].join("\n")
end

#summaryObject



41
42
43
44
# File 'lib/lita/standups/models/standup_schedule.rb', line 41

def summary
  day_text = weekly? ? " on #{day_of_week}" : ""
  "ID: #{id} - running standup #{standup.name} (ID: #{standup.id}) #{repeat}#{day_text} at #{time.strftime("%H:%M")}"
end

#weekly?Boolean

Returns:

  • (Boolean)


60
61
62
# File 'lib/lita/standups/models/standup_schedule.rb', line 60

def weekly?
  repeat == "weekly"
end

#workdays?Boolean

Returns:

  • (Boolean)


64
65
66
# File 'lib/lita/standups/models/standup_schedule.rb', line 64

def workdays?
  repeat == "workdays"
end