Class: AppointmentTime
- Inherits:
-
Object
- Object
- AppointmentTime
- Defined in:
- app/models/medivo/appointment.rb
Instance Attribute Summary collapse
-
#time ⇒ Object
readonly
Returns the value of attribute time.
-
#time_str ⇒ Object
readonly
Returns the value of attribute time_str.
Instance Method Summary collapse
- #date ⇒ Object
-
#initialize(time_str) ⇒ AppointmentTime
constructor
A new instance of AppointmentTime.
-
#match(am_pm, current_time) ⇒ Object
filter out nil times or by am_pm or past times.
- #nearness_to_time(other_time) ⇒ Object
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
#time ⇒ Object (readonly)
Returns the value of attribute time.
123 124 125 |
# File 'app/models/medivo/appointment.rb', line 123 def time @time end |
#time_str ⇒ Object (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
#date ⇒ Object
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 |