Class: RubynCode::Background::Job

Inherits:
Data
  • Object
show all
Defined in:
lib/rubyn_code/background/job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command

Returns:

  • (Object)

    the current value of command



5
6
7
# File 'lib/rubyn_code/background/job.rb', line 5

def command
  @command
end

#completed_atObject (readonly)

Returns the value of attribute completed_at

Returns:

  • (Object)

    the current value of completed_at



5
6
7
# File 'lib/rubyn_code/background/job.rb', line 5

def completed_at
  @completed_at
end

#idObject (readonly)

Returns the value of attribute id

Returns:

  • (Object)

    the current value of id



5
6
7
# File 'lib/rubyn_code/background/job.rb', line 5

def id
  @id
end

#resultObject (readonly)

Returns the value of attribute result

Returns:

  • (Object)

    the current value of result



5
6
7
# File 'lib/rubyn_code/background/job.rb', line 5

def result
  @result
end

#started_atObject (readonly)

Returns the value of attribute started_at

Returns:

  • (Object)

    the current value of started_at



5
6
7
# File 'lib/rubyn_code/background/job.rb', line 5

def started_at
  @started_at
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



5
6
7
# File 'lib/rubyn_code/background/job.rb', line 5

def status
  @status
end

Instance Method Details

#completed?Boolean

Returns:

  • (Boolean)


7
# File 'lib/rubyn_code/background/job.rb', line 7

def completed? = status == :completed

#durationObject



11
12
13
14
15
16
# File 'lib/rubyn_code/background/job.rb', line 11

def duration
  return nil unless started_at
  return nil if running?

  (completed_at || Time.now) - started_at
end

#error?Boolean

Returns:

  • (Boolean)


8
# File 'lib/rubyn_code/background/job.rb', line 8

def error?     = status == :error

#running?Boolean

Returns:

  • (Boolean)


6
# File 'lib/rubyn_code/background/job.rb', line 6

def running?   = status == :running

#timeout?Boolean

Returns:

  • (Boolean)


9
# File 'lib/rubyn_code/background/job.rb', line 9

def timeout?   = status == :timeout