Class: Jbr::Jobs

Inherits:
Resource show all
Includes:
Enumerable, Includable
Defined in:
lib/jbr/jobs.rb

Overview

The jobs on a Jobber account, oldest first, walked a page at a time.

Direct Known Subclasses

Mock::Jobs

Constant Summary collapse

FIELDS =

What a job answers with wherever one is read, before anything it was asked to bring back with it.

'id title instructions jobStatus total createdAt startAt completedAt ' \
'quote { id amounts { total } }'

Instance Attribute Summary

Attributes inherited from Resource

#id

Instance Method Summary collapse

Methods included from Includable

#includes

Methods inherited from Resource

#initialize

Constructor Details

This class inherits a constructor from Jbr::Resource

Instance Method Details

#eachObject

Every job on the account, past and future alike. Nothing is read until the walk starts, and a page is read only once the one before it runs out.



13
# File 'lib/jbr/jobs.rb', line 13

def each(&) = walk.each(&)

#find(id) ⇒ Job?

Shadows Enumerable#find on purpose, the way Active Record does: a job is reached by the ID Jobber files it under, not by asking every job on the account whether it is the one.

Parameters:

  • id (String)

    the Jobber ID of the job.

Returns:

  • (Job, nil)

    nil when Jobber has no job under that ID.



25
26
27
28
# File 'lib/jbr/jobs.rb', line 25

def find(id)
  node = @oauth.query(one, variables: { id: id })['job']
  Job.new node: node if node
end

#pastEnumerator<Job>

Returns the jobs that started before now.

Returns:

  • (Enumerator<Job>)

    the jobs that started before now.



19
# File 'lib/jbr/jobs.rb', line 19

def past = walk until_now

#upcomingEnumerator<Job>

Returns the jobs scheduled from now on.

Returns:

  • (Enumerator<Job>)

    the jobs scheduled from now on.



16
# File 'lib/jbr/jobs.rb', line 16

def upcoming = walk from_now