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.



125
126
127
128
# File 'app/models/medivo/appointment.rb', line 125

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.



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

def time
  @time
end

#time_strObject (readonly)

Returns the value of attribute time_str.



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

def time_str
  @time_str
end

Instance Method Details

#dateObject



130
131
132
# File 'app/models/medivo/appointment.rb', line 130

def date
  @time.to_date
end

#match(am_pm, current_time) ⇒ Object

filter out nil times or by am_pm or past times



135
136
137
# File 'app/models/medivo/appointment.rb', line 135

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

#nearness_to_time(other_time) ⇒ Object



139
140
141
# File 'app/models/medivo/appointment.rb', line 139

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