Class: Turbovax::Appointment
- Inherits:
-
Object
- Object
- Turbovax::Appointment
- Defined in:
- lib/turbovax/appointment.rb
Overview
Class that encapsulates a singular appointment
Instance Attribute Summary collapse
- #is_second_dose ⇒ Boolean
- #time ⇒ DateTime
-
#time_zone ⇒ String
Can automatically be set by Turbovax::Location instance.
- #vaccine_type ⇒ String
Instance Method Summary collapse
-
#initialize(**params) ⇒ Appointment
constructor
A new instance of Appointment.
-
#time_in_time_zone ⇒ DateTime
If time_zone is set on instance, returns appointment time in time zone.
Constructor Details
#initialize(**params) ⇒ Appointment
Returns a new instance of Appointment.
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/turbovax/appointment.rb', line 19 def initialize(**params) params.each do |attribute, value| value_to_save = if attribute.to_s == "time" if value.is_a?(DateTime) || value.is_a?(Time) value else DateTime.parse(value) end else value end send("#{attribute}=", value_to_save) end end |
Instance Attribute Details
#is_second_dose ⇒ Boolean
14 15 16 |
# File 'lib/turbovax/appointment.rb', line 14 def is_second_dose @is_second_dose end |
#time ⇒ DateTime
9 10 11 |
# File 'lib/turbovax/appointment.rb', line 9 def time @time end |
#time_zone ⇒ String
Can automatically be set by Turbovax::Location instance
12 13 14 |
# File 'lib/turbovax/appointment.rb', line 12 def time_zone @time_zone end |
#vaccine_type ⇒ String
16 17 18 |
# File 'lib/turbovax/appointment.rb', line 16 def vaccine_type @vaccine_type end |
Instance Method Details
#time_in_time_zone ⇒ DateTime
If time_zone is set on instance, returns appointment time in time zone
38 39 40 |
# File 'lib/turbovax/appointment.rb', line 38 def time_in_time_zone time_zone ? time.in_time_zone(time_zone) : time end |