Class: Turbovax::Location
- Inherits:
-
Object
- Object
- Turbovax::Location
- Defined in:
- lib/turbovax/location.rb
Overview
Representation of an individual vaccination site
Instance Attribute Summary collapse
- #area ⇒ String
-
#data ⇒ Hash
Use this nested hash to specify appointments, appointment_count, available, vaccine_types.
- #full_address ⇒ String
-
#id ⇒ String
Turbovax-specific unique ID for identification purposes.
- #latitude ⇒ String
- #longitude ⇒ String
-
#metadata ⇒ Hash
Use this attribute to add any metadata.
-
#name ⇒ String
Human readable name.
- #portal ⇒ Turbovax::Portal
-
#portal_id ⇒ String
Portal specific ID.
-
#time_zone ⇒ String
Valid values in api.rubyonrails.org/classes/ActiveSupport/TimeZone.html.
- #zipcode ⇒ String
Instance Method Summary collapse
- #appointment_count ⇒ Object
-
#appointments ⇒ Object
Returns a list of appointment instances (which are defined via) data hash.
-
#available ⇒ Boolean
This can be manually specified via data hash or automatically calculated if appointment_count > 0.
-
#initialize(**params) ⇒ Location
constructor
A new instance of Location.
-
#vaccine_types ⇒ Object
This can be manually specified via data hash or automatically calculated.
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
#area ⇒ String
20 21 22 |
# File 'lib/turbovax/location.rb', line 20 def area @area end |
#data ⇒ Hash
Use this nested hash to specify appointments, appointment_count, available, vaccine_types
32 33 34 |
# File 'lib/turbovax/location.rb', line 32 def data @data end |
#full_address ⇒ String
18 19 20 |
# File 'lib/turbovax/location.rb', line 18 def full_address @full_address end |
#id ⇒ String
Turbovax-specific unique ID for identification purposes
8 9 10 |
# File 'lib/turbovax/location.rb', line 8 def id @id end |
#latitude ⇒ String
24 25 26 |
# File 'lib/turbovax/location.rb', line 24 def latitude @latitude end |
#longitude ⇒ String
26 27 28 |
# File 'lib/turbovax/location.rb', line 26 def longitude @longitude end |
#metadata ⇒ Hash
Use this attribute to add any metadata
35 36 37 |
# File 'lib/turbovax/location.rb', line 35 def @metadata end |
#name ⇒ String
Human readable name
11 12 13 |
# File 'lib/turbovax/location.rb', line 11 def name @name end |
#portal ⇒ Turbovax::Portal
13 14 15 |
# File 'lib/turbovax/location.rb', line 13 def portal @portal end |
#portal_id ⇒ String
Portal specific ID
16 17 18 |
# File 'lib/turbovax/location.rb', line 16 def portal_id @portal_id end |
#time_zone ⇒ String
Valid values in api.rubyonrails.org/classes/ActiveSupport/TimeZone.html
29 30 31 |
# File 'lib/turbovax/location.rb', line 29 def time_zone @time_zone end |
#zipcode ⇒ String
22 23 24 |
# File 'lib/turbovax/location.rb', line 22 def zipcode @zipcode end |
Instance Method Details
#appointment_count ⇒ Object
67 68 69 |
# File 'lib/turbovax/location.rb', line 67 def appointment_count data_hash[:appointment_count] || appointments.size end |
#appointments ⇒ Object
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 |
#available ⇒ Boolean
This can be manually specified via data hash or automatically calculated if appointment_count > 0
46 47 48 |
# File 'lib/turbovax/location.rb', line 46 def available data_hash[:available] || appointment_count.positive? end |
#vaccine_types ⇒ Object
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 |