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.



166
167
168
169
170
# File 'lib/lab_where_client.rb', line 166

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

Instance Attribute Details

#barcodeObject (readonly)

Returns the value of attribute barcode.



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

def barcode
  @barcode
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#parentageObject (readonly)

Returns the value of attribute parentage.



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

def parentage
  @parentage
end

Class Method Details

.children(barcode) ⇒ Object



178
179
180
181
182
183
184
185
186
187
# File 'lib/lab_where_client.rb', line 178

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

  endpoint_name "locations/#{barcode}"

  attrs = LabWhere.new.get(self, 'children')
  return [] if attrs.nil?

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

.find_by_barcode(barcode) ⇒ Object



159
160
161
162
163
164
# File 'lib/lab_where_client.rb', line 159

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



189
190
191
192
193
194
195
196
197
198
# File 'lib/lab_where_client.rb', line 189

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

  endpoint_name "locations/#{barcode}"

  attrs = LabWhere.new.get(self, 'labwares')
  return [] if attrs.nil?

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

Instance Method Details

#location_infoObject



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

def location_info
  return '' if parentage.blank? && name.blank?

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