Class: ODDB::Drugs::ActiveAgent

Inherits:
Model
  • Object
show all
Includes:
Comparable
Defined in:
lib/oddb/export/yaml.rb,
lib/oddb/drugs/active_agent.rb

Constant Summary

Constants included from OddbUri

OddbUri::YAML_URI

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Model

#__odba_delete__, #__odba_save__, _serializables, belongs_to, connections, connector, connectors, #data_origin, #data_origins, delegates, #delete, find_by_uid, has_many, is_coded, m10l_document, multilingual, #odba_serializables, #oid, on_delete, on_save, predicates, #save, #saved?, serializables, serialize, singular

Methods included from ODBA::Persistable

#to_yaml_properties

Methods included from Yaml

append_features, #to_yaml_properties

Methods included from OddbUri

#to_yaml, #to_yaml_map, #to_yaml_type

Constructor Details

#initialize(substance, dose, unit = "mg") ⇒ ActiveAgent

Returns a new instance of ActiveAgent.



14
15
16
17
18
19
20
21
# File 'lib/oddb/drugs/active_agent.rb', line 14

def initialize(substance, dose, unit="mg")
  @substance = substance
  if(dose.is_a?(Dose))
    @dose = dose
  else
    @dose = Dose.new(dose, unit)
  end
end

Instance Attribute Details

#chemical_equivalenceObject

Returns the value of attribute chemical_equivalence.



13
14
15
# File 'lib/oddb/drugs/active_agent.rb', line 13

def chemical_equivalence
  @chemical_equivalence
end

#doseObject

Returns the value of attribute dose.



13
14
15
# File 'lib/oddb/drugs/active_agent.rb', line 13

def dose
  @dose
end

Instance Method Details

#<=>(other) ⇒ Object



25
26
27
# File 'lib/oddb/drugs/active_agent.rb', line 25

def <=>(other)
  [@substance, @dose] <=> [other.substance, other.dose]
end

#==(other) ⇒ Object



28
29
30
31
32
33
34
# File 'lib/oddb/drugs/active_agent.rb', line 28

def ==(other)
  other.is_a?(ActiveAgent) \
    && ([@substance, @dose] == [other.substance, other.dose] \
        || @chemical_equivalence == other \
        || ((other = other.chemical_equivalence) && self == other)) \
    || false
end

#to_s(language = :de) ⇒ Object



22
23
24
# File 'lib/oddb/drugs/active_agent.rb', line 22

def to_s(language=:de)
  [@substance.name.send(language), @dose].join(' ')
end