Class: Turbovax::Appointment

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

Overview

Class that encapsulates a singular appointment

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**params) ⇒ Appointment

Returns a new instance of Appointment.

Parameters:

  • params

    hash mapping of attribute => value



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_doseBoolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/turbovax/appointment.rb', line 14

def is_second_dose
  @is_second_dose
end

#timeDateTime

Returns:

  • (DateTime)


9
10
11
# File 'lib/turbovax/appointment.rb', line 9

def time
  @time
end

#time_zoneString

Can automatically be set by Turbovax::Location instance

Returns:

  • (String)


12
13
14
# File 'lib/turbovax/appointment.rb', line 12

def time_zone
  @time_zone
end

#vaccine_typeString

Returns:

  • (String)


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

def vaccine_type
  @vaccine_type
end

Instance Method Details

#time_in_time_zoneDateTime

If time_zone is set on instance, returns appointment time in time zone

Returns:

  • (DateTime)


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