class Scron::History
- Scron::History
- Reference
- Object
Overview
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
.
Defined in:
scron/history.crConstructors
-
.new(text : String, now : Time)
Instantiates a new history.
Instance Method Summary
-
#[](command)
Returns Time for the last time this command ran.
-
#has?(command)
Returns true if this command ever ran at least once.
-
#to_s(io)
Returns history database as string via string builder pattern to save memory.
-
#to_s
Returns history database as string, meant to be saved to ~/.scrondb file.
-
#touch(command)
Sets timestamp to current time.
Constructor Detail
def self.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")
Instance Method Detail
def touch(command)
#
Sets timestamp to current time. This method should be called whenever the command runs.