Class: Accession::Tag

Inherits:
Object
  • Object
show all
Includes:
Equality, HelperTagValue, ActiveModel::Model
Defined in:
lib/accession/accession/tag.rb

Overview

A tag relates to a sample attribute. It provides all of the relevant information for that attribute i.e. which service it is required for and which groups it will be assigned to in the xml.

Direct Known Subclasses

TagCollectionDate, TagCountryOfOrigin

Defined Under Namespace

Modules: HelperTagValue

Constant Summary collapse

DEFAULT_ATTRIBUTES =
{ services: [] }.freeze

Constants included from HelperTagValue

HelperTagValue::MISING_THIRD_PARTY_DATA, HelperTagValue::MISSING_CONTROL_SAMPLE, HelperTagValue::MISSING_DATA_AGGREEMENT_PRE2023, HelperTagValue::MISSING_ENDANGERED_SPECIES, HelperTagValue::MISSING_HUMAN_IDENTIFIABLE, HelperTagValue::MISSING_LAB_STOCK, HelperTagValue::MISSING_SAMPLE_GROUP, HelperTagValue::MISSING_SYNTHETIC_CONSTRUCT, HelperTagValue::NOT_APPLICABLE_CONTROL_SAMPLE, HelperTagValue::NOT_APPLICABLE_SAMPLE_GROUP, HelperTagValue::NOT_COLLECTED, HelperTagValue::NOT_PROVIDED, HelperTagValue::OTHER_DEFAULT_SETTINGS, HelperTagValue::RESTRICTED_ACCESS

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HelperTagValue

#incorrect_format_value, #value_for

Methods included from Equality

#<=>, #to_a

Constructor Details

#initialize(attributes = {}) ⇒ Tag

Returns a new instance of Tag.



17
18
19
# File 'lib/accession/accession/tag.rb', line 17

def initialize(attributes = {})
  super(DEFAULT_ATTRIBUTES.merge(attributes))
end

Instance Attribute Details

#class_nameObject

Returns the value of attribute class_name.



11
12
13
# File 'lib/accession/accession/tag.rb', line 11

def class_name
  @class_name
end

#ebi_nameObject

Returns the value of attribute ebi_name.



11
12
13
# File 'lib/accession/accession/tag.rb', line 11

def ebi_name
  @ebi_name
end

#groupsObject

Returns the value of attribute groups.



11
12
13
# File 'lib/accession/accession/tag.rb', line 11

def groups
  @groups
end

#nameObject

Returns the value of attribute name.



11
12
13
# File 'lib/accession/accession/tag.rb', line 11

def name
  @name
end

#servicesObject

Returns the value of attribute services.



11
12
13
# File 'lib/accession/accession/tag.rb', line 11

def services
  @services
end

#valueObject

Returns the value of attribute value.



11
12
13
# File 'lib/accession/accession/tag.rb', line 11

def value
  @value
end

Instance Method Details

#add_value(value) ⇒ Object



45
46
47
48
# File 'lib/accession/accession/tag.rb', line 45

def add_value(value)
  self.value = value
  self
end

#array_express?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/accession/accession/tag.rb', line 33

def array_express?
  array_express
end

#array_express_labelObject



54
55
56
# File 'lib/accession/accession/tag.rb', line 54

def array_express_label
  "ArrayExpress-#{label}"
end

#attributesObject



58
59
60
# File 'lib/accession/accession/tag.rb', line 58

def attributes
  %i[services value name groups ebi_name]
end

#labelObject



50
51
52
# File 'lib/accession/accession/tag.rb', line 50

def label
  (ebi_name || name).to_s.upcase
end

#required_for?(service) ⇒ Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/accession/accession/tag.rb', line 29

def required_for?(service)
  services.include? service.provider
end

#sample_attributes?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/accession/accession/tag.rb', line 41

def sample_attributes?
  sample_attributes
end

#sample_name?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/accession/accession/tag.rb', line 37

def sample_name?
  sample_name
end