Class: Sibling

Inherits:
Object
  • Object
show all
Defined in:
app/models/sibling.rb

Overview

Used by the final tube form, siblings describe other tubes that are part of the same submission, as well as placeholders for tubes which are still due to be created.

Constant Summary collapse

READY_STATE =

The state in which a sibling must be to allow pooling.

'passed'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Sibling

Returns a new instance of Sibling.



12
13
14
15
16
17
18
19
20
21
22
# File 'app/models/sibling.rb', line 12

def initialize(options)
  if options.respond_to?(:fetch)
    @name = options.fetch('name', 'UNKNOWN')
    @uuid = options.fetch('uuid', nil)
    @barcode = options.fetch('ean13_barcode', 'UNKNOWN')
    @sanger_barcode = SBCF::SangerBarcode.from_machine(options.fetch('ean13_barcode', 'UNKNOWN'))
    @state = options.fetch('state', 'UNKNOWN')
  else
    missing_sibling
  end
end

Instance Attribute Details

#barcodeObject (readonly)

Returns the value of attribute barcode.



10
11
12
# File 'app/models/sibling.rb', line 10

def barcode
  @barcode
end

#nameObject (readonly)

Returns the value of attribute name.



10
11
12
# File 'app/models/sibling.rb', line 10

def name
  @name
end

#sanger_barcodeObject (readonly)

Returns the value of attribute sanger_barcode.



10
11
12
# File 'app/models/sibling.rb', line 10

def sanger_barcode
  @sanger_barcode
end

#stateObject (readonly)

Returns the value of attribute state.



10
11
12
# File 'app/models/sibling.rb', line 10

def state
  @state
end

#uuidObject (readonly)

Returns the value of attribute uuid.



10
11
12
# File 'app/models/sibling.rb', line 10

def uuid
  @uuid
end

Instance Method Details

#messageObject



24
25
26
27
28
29
# File 'app/models/sibling.rb', line 24

def message
  return 'This tube is ready for pooling, find it, and scan it in above' if state == READY_STATE
  return 'Some requests still need to be progressed to appropriate tubes' if state == 'Not Present'

  "Must be #{READY_STATE.humanize} first"
end

#ready?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/models/sibling.rb', line 31

def ready?
  state == READY_STATE
end