Class: Wheneverd::Trigger::Calendar
- Inherits:
-
Object
- Object
- Wheneverd::Trigger::Calendar
- Includes:
- Base
- Defined in:
- lib/wheneverd/trigger/calendar.rb
Overview
A calendar trigger, rendered as one or more OnCalendar= lines.
Instance Attribute Summary collapse
-
#on_calendar ⇒ Array<String>
readonly
Calendar specs (already in
systemdOnCalendar format).
Instance Method Summary collapse
-
#initialize(on_calendar:) ⇒ Calendar
constructor
A new instance of Calendar.
-
#signature ⇒ String
Stable signature for unit naming.
-
#systemd_timer_lines ⇒ Array<String>
Systemd
[Timer]lines for this trigger.
Constructor Details
#initialize(on_calendar:) ⇒ Calendar
Returns a new instance of Calendar.
13 14 15 16 17 18 19 20 |
# File 'lib/wheneverd/trigger/calendar.rb', line 13 def initialize(on_calendar:) unless on_calendar.is_a?(Array) && !on_calendar.empty? && on_calendar.all? { |v| v.is_a?(String) && !v.strip.empty? } raise ArgumentError, "on_calendar must be a non-empty Array of non-empty Strings" end @on_calendar = on_calendar.map(&:strip) end |
Instance Attribute Details
#on_calendar ⇒ Array<String> (readonly)
Returns calendar specs (already in systemd OnCalendar format).
10 11 12 |
# File 'lib/wheneverd/trigger/calendar.rb', line 10 def on_calendar @on_calendar end |
Instance Method Details
#signature ⇒ String
Returns stable signature for unit naming.
28 29 30 |
# File 'lib/wheneverd/trigger/calendar.rb', line 28 def signature "calendar:#{on_calendar.sort.join('|')}" end |
#systemd_timer_lines ⇒ Array<String>
Returns systemd [Timer] lines for this trigger.
23 24 25 |
# File 'lib/wheneverd/trigger/calendar.rb', line 23 def systemd_timer_lines on_calendar.map { |spec| "OnCalendar=#{spec}" } end |