Class: HermesAgent::Client::Entities::JobSchedule

Inherits:
HermesAgent::Client::Entity show all
Defined in:
lib/hermes_agent/client/entities/job.rb

Overview

The schedule of a Job (HermesAgent::Client::Entities::Job#schedule): a tagged union discriminated by #kind. The create/update schedule string is parsed server-side into one of three kinds, each carrying its own payload:

  • "once" — a one-shot run at #run_at (an ISO-8601 string).
  • "interval" — a recurring run every #minutes minutes.
  • "cron" — a recurring run on the cron expression #expr.

Use the #once? / #interval? / #cron? predicates to discriminate. The payload readers (#run_at / #minutes / #expr) return nil when the schedule is not of their kind. #display is a human-readable form of the schedule for any kind. Field readers are best-effort; HermesAgent::Client::Entity#to_h remains the source of truth.

Instance Method Summary collapse

Methods inherited from HermesAgent::Client::Entity

#==, #[], #eql?, #hash, #to_h

Instance Method Details

#cron?boolean

Whether this is a recurring cron ("cron") schedule.

Returns:

  • (boolean)


76
77
78
# File 'lib/hermes_agent/client/entities/job.rb', line 76

def cron?
  kind == "cron"
end

#displayString?

A human-readable rendering of the schedule (e.g. "every 120m", "0 9 * * *", or "once at 2027-02-03 14:00").

Returns:

  • (String, nil)


85
86
87
# File 'lib/hermes_agent/client/entities/job.rb', line 85

def display
  self["display"]
end

#exprString?

The cron expression of a "cron" schedule. Returns nil when the schedule is not of kind "cron".

Returns:

  • (String, nil)


112
113
114
# File 'lib/hermes_agent/client/entities/job.rb', line 112

def expr
  self["expr"]
end

#interval?boolean

Whether this is a recurring interval ("interval") schedule.

Returns:

  • (boolean)


68
69
70
# File 'lib/hermes_agent/client/entities/job.rb', line 68

def interval?
  kind == "interval"
end

#kindString?

The schedule kind: "once", "interval", or "cron".

Returns:

  • (String, nil)


52
53
54
# File 'lib/hermes_agent/client/entities/job.rb', line 52

def kind
  self["kind"]
end

#minutesInteger?

The interval in minutes of an "interval" schedule. Returns nil when the schedule is not of kind "interval".

Returns:

  • (Integer, nil)


103
104
105
# File 'lib/hermes_agent/client/entities/job.rb', line 103

def minutes
  self["minutes"]
end

#once?boolean

Whether this is a one-shot ("once") schedule.

Returns:

  • (boolean)


60
61
62
# File 'lib/hermes_agent/client/entities/job.rb', line 60

def once?
  kind == "once"
end

#run_atString?

The scheduled run time of a "once" schedule, as an ISO-8601 string. Returns nil when the schedule is not of kind "once".

Returns:

  • (String, nil)


94
95
96
# File 'lib/hermes_agent/client/entities/job.rb', line 94

def run_at
  self["run_at"]
end