Class: Arcp::Job::Summary

Inherits:
Data
  • Object
show all
Defined in:
lib/arcp/job/summary.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#agentObject (readonly)

Returns the value of attribute agent

Returns:

  • (Object)

    the current value of agent



5
6
7
# File 'lib/arcp/job/summary.rb', line 5

def agent
  @agent
end

#budget_remainingObject (readonly)

Returns the value of attribute budget_remaining

Returns:

  • (Object)

    the current value of budget_remaining



5
6
7
# File 'lib/arcp/job/summary.rb', line 5

def budget_remaining
  @budget_remaining
end

#created_atObject (readonly)

Returns the value of attribute created_at

Returns:

  • (Object)

    the current value of created_at



5
6
7
# File 'lib/arcp/job/summary.rb', line 5

def created_at
  @created_at
end

#job_idObject (readonly)

Returns the value of attribute job_id

Returns:

  • (Object)

    the current value of job_id



5
6
7
# File 'lib/arcp/job/summary.rb', line 5

def job_id
  @job_id
end

#lease_expires_atObject (readonly)

Returns the value of attribute lease_expires_at

Returns:

  • (Object)

    the current value of lease_expires_at



5
6
7
# File 'lib/arcp/job/summary.rb', line 5

def lease_expires_at
  @lease_expires_at
end

#statusObject (readonly)

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



5
6
7
# File 'lib/arcp/job/summary.rb', line 5

def status
  @status
end

Class Method Details

.from_h(h) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/arcp/job/summary.rb', line 6

def self.from_h(h)
  h = h.transform_keys(&:to_s)
  new(
    job_id: h.fetch('job_id'),
    agent: h.fetch('agent'),
    status: h.fetch('status'),
    created_at: h['created_at'],
    lease_expires_at: h['lease_expires_at'],
    budget_remaining: h['budget_remaining']
  )
end

Instance Method Details

#to_hObject



18
19
20
21
22
23
24
# File 'lib/arcp/job/summary.rb', line 18

def to_h
  out = { 'job_id' => job_id, 'agent' => agent, 'status' => status }
  out['created_at']       = created_at if created_at
  out['lease_expires_at'] = lease_expires_at if lease_expires_at
  out['budget_remaining'] = budget_remaining if budget_remaining
  out
end