class Turbovax::Location

Representation of an individual vaccination site

Attributes

area[RW]

@return [String]

data[RW]

@return [Hash] Use this nested hash to specify appointments, appointment_count, available, vaccine_types

full_address[RW]

@return [String]

id[RW]

@return [String] Turbovax-specific unique ID for identification purposes

latitude[RW]

@return [String]

longitude[RW]

@return [String]

metadata[RW]

@return [Hash] Use this attribute to add any metadata

name[RW]

@return [String] Human readable name

portal[RW]

@return [Turbovax::Portal]

portal_id[RW]

@return [String] Portal specific ID

time_zone[RW]
zipcode[RW]

@return [String]

Public Class Methods

new(**params) click to toggle source
# File lib/turbovax/location.rb, line 37
def initialize(**params)
  params.each do |attribute, value|
    send("#{attribute}=", value)
  end
end

Public Instance Methods

appointment_count() click to toggle source
# File lib/turbovax/location.rb, line 67
def appointment_count
  data_hash[:appointment_count] || appointments.size
end
appointments() click to toggle source

Returns a list of appointment instances (which are defined via) data hash

# File lib/turbovax/location.rb, line 56
def appointments
  Array(data_hash[:appointments]).map do |appointment|
    if appointment.is_a?(Turbovax::Appointment)
      appointment.time_zone = time_zone
      appointment
    else
      Turbovax::Appointment.new(appointment.merge(time_zone: time_zone))
    end
  end
end
available() click to toggle source

@return [Boolean] This can be manually specified via data hash or automatically calculated if appointment_count > 0

# File lib/turbovax/location.rb, line 46
def available
  data_hash[:available] || appointment_count.positive?
end
vaccine_types() click to toggle source

This can be manually specified via data hash or automatically calculated

# File lib/turbovax/location.rb, line 51
def vaccine_types
  data_hash[:vaccine_types] || appointments.map(&:vaccine_type).uniq
end

Private Instance Methods

data_hash() click to toggle source
# File lib/turbovax/location.rb, line 73
def data_hash
  data || {}
end