Class: ODDB::Drugs::Atc
- Inherits:
-
Model
- Object
- Model
- ODDB::Drugs::Atc
show all
- Defined in:
- lib/oddb/drugs/atc.rb,
lib/oddb/export/yaml.rb,
lib/oddb/persistence/odba/drugs/atc.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
#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(code) ⇒ Atc
Returns a new instance of Atc.
15
16
17
|
# File 'lib/oddb/drugs/atc.rb', line 15
def initialize(code)
@code = code
end
|
Instance Attribute Details
#code ⇒ Object
Returns the value of attribute code.
11
12
13
|
# File 'lib/oddb/drugs/atc.rb', line 11
def code
@code
end
|
Instance Method Details
#<=>(other) ⇒ Object
48
49
50
|
# File 'lib/oddb/drugs/atc.rb', line 48
def <=>(other)
@code <=> other.code
end
|
#interesting? ⇒ Boolean
18
19
20
|
# File 'lib/oddb/drugs/atc.rb', line 18
def interesting?
!(ddds.empty? && guidelines.empty? && ddd_guidelines.empty?)
end
|
#level ⇒ Object
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/oddb/drugs/atc.rb', line 21
def level
case len = @code.length
when 7
5
when 1
len
else
len - 1
end
end
|
#parent ⇒ Object
31
32
33
|
# File 'lib/oddb/drugs/atc.rb', line 31
def parent
Atc.find_by_code(parent_code)
end
|
#parent_code ⇒ Object
34
35
36
37
38
39
40
41
|
# File 'lib/oddb/drugs/atc.rb', line 34
def parent_code
case level
when 2
@code[0,1]
when 3..5
@code[0,level]
end
end
|
#products ⇒ Object
42
43
44
|
# File 'lib/oddb/drugs/atc.rb', line 42
def products
sequences.collect { |sequence| sequence.product }.uniq
end
|
#to_s ⇒ Object
45
46
47
|
# File 'lib/oddb/drugs/atc.rb', line 45
def to_s
@code.to_s
end
|