class

Scron::History

Inherits Reference < Object

Keeps track of the last time a command ran. When a command runs, update the timestamp with Scron::History#touch. The entire history database can be written to a string with Scron::History#to_s.

Constructors

new(text : String, now : Time)

Instantiates a new history. Example history format looks like:

2020-01-01.06:00 /path/to/command1
2020-02-05.22:15 /path/to/command2 arg1 arg2

Example usage:

Scron::History.new("2020-01-01.06:00 /path/to/command1")
Source

Instance methods

[](command)

Returns Time for the last time this command ran. Raises error if it never ran.

Source
has?(command)

Returns true if this command ever ran at least once.

Source
to_s(io)

Returns history database as string via string builder pattern to save memory.

Source
to_s

Returns history database as string, meant to be saved to ~/.scrondb file.

Source
touch(command)

Sets timestamp to current time. This method should be called whenever the command runs.

Source