Class: LabWhereClient::Location

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

Overview

rubocop:todo Style/Documentation

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.


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

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

Instance Attribute Details

#barcodeObject (readonly)

Returns the value of attribute barcode


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

def barcode
  @barcode
end

#nameObject (readonly)

Returns the value of attribute name


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

def name
  @name
end

#parentageObject (readonly)

Returns the value of attribute parentage


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

def parentage
  @parentage
end

Class Method Details

.children(barcode) ⇒ Object


183
184
185
186
187
188
189
190
# File 'lib/lab_where_client.rb', line 183

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


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

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


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

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


177
178
179
180
181
# File 'lib/lab_where_client.rb', line 177

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

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