Class: DeviceTracker::Device
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- DeviceTracker::Device
- Defined in:
- lib/device_tracker/models/device.rb
Instance Method Summary collapse
- #checked_out_since_formatted ⇒ Object
- #days_checked_out ⇒ Object
- #full_name ⇒ Object
- #passed_use_by_date? ⇒ Boolean
- #unid=(unid) ⇒ Object
Instance Method Details
#checked_out_since_formatted ⇒ Object
27 28 29 |
# File 'lib/device_tracker/models/device.rb', line 27 def checked_out_since_formatted self[:checked_out_since].strftime('%A, %d %B %Y at %I:%M%p') end |
#days_checked_out ⇒ Object
31 32 33 |
# File 'lib/device_tracker/models/device.rb', line 31 def days_checked_out (Time.now.to_date - self[:checked_out_since].to_date).floor end |
#full_name ⇒ Object
19 20 21 |
# File 'lib/device_tracker/models/device.rb', line 19 def full_name self[:manufacturer] + ' ' + self[:device] end |
#passed_use_by_date? ⇒ Boolean
23 24 25 |
# File 'lib/device_tracker/models/device.rb', line 23 def passed_use_by_date? (!self[:available] && (Time.now - self[:checked_out_since]).to_i / 1.day >= 3) end |
#unid=(unid) ⇒ Object
15 16 17 |
# File 'lib/device_tracker/models/device.rb', line 15 def unid=(unid) self[:unid] = unid.upcase end |