Class: Company::Visits

Inherits:
Collection show all
Defined in:
lib/company/collections/visits.rb

Overview

The visits of a business: every stop somebody is booked for, of a job or of a lead where the work is still being looked at. A gem answers create where its platform books a stop against a lead, and for_jobs or for_leads where it can ask its platform for one kind alone; where it cannot, the list is walked and the other kind let go.

Instance Method Summary collapse

Methods inherited from Collection

#ids, #includes, #of, #past, #upcoming

Instance Method Details

#create(name:, surname:, phone:, email:, address:, description:, notes:, source:, starts_at:, ends_at:, technicians:) ⇒ Visit

Books a stop to look at work nobody has priced yet, opening the customer and whatever the platform hangs the stop off wherever it has none.

Parameters:

  • name (String) —

    given name of who asked, or the business's where a person has none.

  • surname (String, nil) —

    their surname.

  • phone (String, nil) —

    number they are reached on.

  • email (String, nil) —

    address they are written to.

  • address (Hash, nil) —

    where the work would happen: :street, :city, :state and :zip.

  • description (String) —

    what the work is called.

  • notes (String, nil) —

    what else was said about it.

  • source (String, nil) —

    where the lead came from, as the business names its sources.

  • starts_at (Time) —

    moment somebody is booked to arrive.

  • ends_at (Time, nil) —

    moment they are booked to leave, or nothing for the platform's.

  • technicians (Array<Technician>) —

    whoever is booked to go.

Returns:

  • (Visit) —

    stop as the platform booked it.

Raises:

  • (NotImplementedError)


21
22
23
24
# File 'lib/company/collections/visits.rb', line 21

def create(name:, surname:, phone:, email:, address:, description:, notes:, source:,
  starts_at:, ends_at:, technicians:)
  raise NotImplementedError, "#{self.class} does not book a visit"
end

#for_jobs ⇒ Collection

Returns the same list, narrowed to the stops of jobs.

Returns:

  • (Collection) —

    the same list, narrowed to the stops of jobs.



27
# File 'lib/company/collections/visits.rb', line 27

def for_jobs = Selection.new(collection: self, &:job)

#for_leads ⇒ Collection

Returns the same list, narrowed to the stops of leads.

Returns:

  • (Collection) —

    the same list, narrowed to the stops of leads.



30
# File 'lib/company/collections/visits.rb', line 30

def for_leads = Selection.new(collection: self, &:lead)

#for_work ⇒ Collection

Booked time a platform can say something about: the stops of jobs and of leads together, without the hours blocked out around them, which name no work and cost a list of their own on a platform that files them apart.

Returns:

  • (Collection) —

    the same list, narrowed to the stops of work of either kind.



36
# File 'lib/company/collections/visits.rb', line 36

def for_work = Selection.new(collection: self) { |visit| visit.job || visit.lead }