Class: DeviceTracker::Device

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
lib/device_tracker/models/device.rb

Instance Method Summary collapse

Instance Method Details

#checked_out_since_formattedObject



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_outObject



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_nameObject



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

Returns:

  • (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