Class: Turbovax::Location

Inherits:
Object
  • Object
show all
Defined in:
lib/turbovax/location.rb

Overview

Representation of an individual vaccination site

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**params) ⇒ Location

Returns a new instance of Location.



37
38
39
40
41
# File 'lib/turbovax/location.rb', line 37

def initialize(**params)
  params.each do |attribute, value|
    send("#{attribute}=", value)
  end
end

Instance Attribute Details

#areaString

Returns:

  • (String)


20
21
22
# File 'lib/turbovax/location.rb', line 20

def area
  @area
end

#dataHash

Use this nested hash to specify appointments, appointment_count, available, vaccine_types

Returns:

  • (Hash)


32
33
34
# File 'lib/turbovax/location.rb', line 32

def data
  @data
end

#full_addressString

Returns:

  • (String)


18
19
20
# File 'lib/turbovax/location.rb', line 18

def full_address
  @full_address
end

#idString

Turbovax-specific unique ID for identification purposes

Returns:

  • (String)


8
9
10
# File 'lib/turbovax/location.rb', line 8

def id
  @id
end

#latitudeString

Returns:

  • (String)


24
25
26
# File 'lib/turbovax/location.rb', line 24

def latitude
  @latitude
end

#longitudeString

Returns:

  • (String)


26
27
28
# File 'lib/turbovax/location.rb', line 26

def longitude
  @longitude
end

#metadataHash

Use this attribute to add any metadata

Returns:

  • (Hash)


35
36
37
# File 'lib/turbovax/location.rb', line 35

def 
  @metadata
end

#nameString

Human readable name

Returns:

  • (String)


11
12
13
# File 'lib/turbovax/location.rb', line 11

def name
  @name
end

#portalTurbovax::Portal

Returns:



13
14
15
# File 'lib/turbovax/location.rb', line 13

def portal
  @portal
end

#portal_idString

Portal specific ID

Returns:

  • (String)


16
17
18
# File 'lib/turbovax/location.rb', line 16

def portal_id
  @portal_id
end

#time_zoneString

Returns:

  • (String)


29
30
31
# File 'lib/turbovax/location.rb', line 29

def time_zone
  @time_zone
end

#zipcodeString

Returns:

  • (String)


22
23
24
# File 'lib/turbovax/location.rb', line 22

def zipcode
  @zipcode
end

Instance Method Details

#appointment_countObject



67
68
69
# File 'lib/turbovax/location.rb', line 67

def appointment_count
  data_hash[:appointment_count] || appointments.size
end

#appointmentsObject

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



56
57
58
59
60
61
62
63
64
65
# 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

#availableBoolean

This can be manually specified via data hash or automatically calculated if appointment_count > 0

Returns:

  • (Boolean)


46
47
48
# File 'lib/turbovax/location.rb', line 46

def available
  data_hash[:available] || appointment_count.positive?
end

#vaccine_typesObject

This can be manually specified via data hash or automatically calculated



51
52
53
# File 'lib/turbovax/location.rb', line 51

def vaccine_types
  data_hash[:vaccine_types] || appointments.map(&:vaccine_type).uniq
end