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
- #nearness_to_time(other_time) ⇒ Object
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
#time ⇒ Object (readonly)
Returns the value of attribute time.
108 109 110 |
# File 'app/models/medivo/appointment.rb', line 108 def time @time end |
#time_str ⇒ Object (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
#date ⇒ Object
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 |