Class: AppointmentTime

Inherits:
Object
  • Object
show all
Defined in:
app/models/medivo/appointment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(time_str) ⇒ AppointmentTime

Returns a new instance of AppointmentTime.



110
111
112
113
# File 'app/models/medivo/appointment.rb', line 110

def initialize(time_str)
  @time_str = time_str
  @time = Time.strptime(time_str, Medivo::Appointment::LABCORP_FORMAT) rescue nil
end

Instance Attribute Details

#timeObject (readonly)

Returns the value of attribute time.



108
109
110
# File 'app/models/medivo/appointment.rb', line 108

def time
  @time
end

#time_strObject (readonly)

Returns the value of attribute time_str.



108
109
110
# File 'app/models/medivo/appointment.rb', line 108

def time_str
  @time_str
end

Instance Method Details

#dateObject



115
116
117
# File 'app/models/medivo/appointment.rb', line 115

def date
  @time.to_date
end

#match(am_pm, current_time) ⇒ Object



119
120
121
# File 'app/models/medivo/appointment.rb', line 119

def match(am_pm, current_time)
  time and time_str.match(/#{am_pm}/) and (time >= current_time)
end

#nearness_to_time(other_time) ⇒ Object



123
124
125
# File 'app/models/medivo/appointment.rb', line 123

def nearness_to_time(other_time)
  (time - other_time).to_i.abs
end