Class: Crontinel::TaskRun

Inherits:
Object
  • Object
show all
Defined in:
lib/crontinel.rb

Overview

Represents a single scheduled task / cron job run

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs = {}) ⇒ TaskRun

Returns a new instance of TaskRun.



33
34
35
36
37
38
39
40
41
# File 'lib/crontinel.rb', line 33

def initialize(attrs = {})
  @id = attrs["id"]
  @name = attrs["command"] || attrs["name"]
  @started_at = attrs["started_at"] ? Time.parse(attrs["started_at"]) : nil
  @finished_at = attrs["finished_at"] ? Time.parse(attrs["finished_at"]) : nil
  @status = attrs["last_status"] || attrs["status"] || "unknown"
  @duration_ms = attrs["duration_ms"]
  @output = attrs["output"]
end

Instance Attribute Details

#duration_msObject (readonly)

Returns the value of attribute duration_ms.



31
32
33
# File 'lib/crontinel.rb', line 31

def duration_ms
  @duration_ms
end

#finished_atObject (readonly)

Returns the value of attribute finished_at.



31
32
33
# File 'lib/crontinel.rb', line 31

def finished_at
  @finished_at
end

#idObject (readonly)

Returns the value of attribute id.



31
32
33
# File 'lib/crontinel.rb', line 31

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



31
32
33
# File 'lib/crontinel.rb', line 31

def name
  @name
end

#outputObject (readonly)

Returns the value of attribute output.



31
32
33
# File 'lib/crontinel.rb', line 31

def output
  @output
end

#started_atObject (readonly)

Returns the value of attribute started_at.



31
32
33
# File 'lib/crontinel.rb', line 31

def started_at
  @started_at
end

#statusObject (readonly)

Returns the value of attribute status.



31
32
33
# File 'lib/crontinel.rb', line 31

def status
  @status
end

Instance Method Details

#failed?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/crontinel.rb', line 47

def failed?
  @status == "failed"
end

#running?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/crontinel.rb', line 51

def running?
  @status == "running"
end

#success?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/crontinel.rb', line 43

def success?
  @status == "completed" || @status == "success"
end