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.



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

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

Instance Attribute Details

#barcodeObject (readonly)

Returns the value of attribute barcode.



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

def barcode
  @barcode
end

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#parentageObject (readonly)

Returns the value of attribute parentage.



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

def parentage
  @parentage
end

Class Method Details

.children(barcode) ⇒ Object



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

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



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

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



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

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



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

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

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