Class: LabWhereClient::Location

Inherits:
Endpoint
  • Object
show all
Defined in:
lib/lab_where_client.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Endpoint

endpoint_name

Constructor Details

#initialize(params) ⇒ Location

Returns a new instance of Location


151
152
153
154
155
# File 'lib/lab_where_client.rb', line 151

def initialize(params)
  @name = params['name']
  @parentage = params['parentage']
  @barcode = params['barcode']
end

Instance Attribute Details

#barcodeObject (readonly)

Returns the value of attribute barcode


142
143
144
# File 'lib/lab_where_client.rb', line 142

def barcode
  @barcode
end

#nameObject (readonly)

Returns the value of attribute name


140
141
142
# File 'lib/lab_where_client.rb', line 140

def name
  @name
end

#parentageObject (readonly)

Returns the value of attribute parentage


141
142
143
# File 'lib/lab_where_client.rb', line 141

def parentage
  @parentage
end

Class Method Details

.children(barcode) ⇒ Object


161
162
163
164
165
166
167
168
# File 'lib/lab_where_client.rb', line 161

def self.children(barcode)
  return [] if barcode.blank?

  attrs = LabWhere.new.get(self, "#{barcode}/children")
  return [] if attrs.nil?

  attrs.map { |locn_params| new(locn_params) }
end

.find_by_barcode(barcode) ⇒ Object


144
145
146
147
148
149
# File 'lib/lab_where_client.rb', line 144

def self.find_by_barcode(barcode)
  return nil if barcode.blank?

  attrs = LabWhere.new.get(self, barcode)
  new(attrs) unless attrs.nil?
end

.labwares(barcode) ⇒ Object


170
171
172
173
174
175
176
177
# File 'lib/lab_where_client.rb', line 170

def self.labwares(barcode)
  return [] if barcode.blank?

  attrs = LabWhere.new.get(self, "#{barcode}/labwares")
  return [] if attrs.nil?

  attrs.map { |labware_params| Labware.new(labware_params) }
end

Instance Method Details

#location_infoObject


157
158
159
# File 'lib/lab_where_client.rb', line 157

def location_info
  [parentage, name].join(' - ')
end