Class: Robot

Inherits:
ApplicationRecord show all
Includes:
ModelExtensions::Robot, Uuid::Uuidable
Defined in:
app/models/robot.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Uuid::Uuidable

included, #unsaved_uuid!, #uuid

Methods inherited from ApplicationRecord

convert_labware_to_receptacle_for, find_by_id_or_name, find_by_id_or_name!

Methods included from Warren::BroadcastMessages

#broadcast, included, #queue_associated_for_broadcast, #queue_for_broadcast, #warren

Class Method Details

.find_by_barcode(code) ⇒ Object Also known as: find_from_barcode


26
27
28
29
# File 'app/models/robot.rb', line 26

def find_by_barcode(code)
  human_robot_barcode = Barcode.number_to_human(code)
  Robot.find_by(barcode: human_robot_barcode) || Robot.find_by(id: human_robot_barcode)
end

.prefixObject


22
23
24
# File 'app/models/robot.rb', line 22

def prefix
  'RB'
end

.valid_barcode?(code) ⇒ Boolean

Returns:

  • (Boolean)

31
32
33
34
35
36
37
# File 'app/models/robot.rb', line 31

def valid_barcode?(code)
  Barcode.barcode_to_human!(code, prefix)
  find_from_barcode(code) # an exception is raise if not found
  true
rescue
  false
end

Instance Method Details

#max_bedsObject


17
18
19
# File 'app/models/robot.rb', line 17

def max_beds
  max_plates_property.try(:value).to_i
end