Class: ODDB::AtcClass

Inherits:
Object show all
Includes:
Language, OddbYaml, SequenceObserver
Defined in:
src/model/atcclass.rb,
ext/export/src/oddb_yaml.rb,
test/test_model/atcclass.rb

Defined Under Namespace

Classes: DDD

Constant Summary

ODBA_SERIALIZABLE =
[ '@descriptions' ]
EXPORT_PROPERTIES =
[
  '@code',
  '@descriptions',
  '@guidelines',
  '@ddd_guidelines',
  '@ddds',
]

Constants included from OddbYaml

EXPORT_PROPERTIES, YAML_URI

Constants included from Persistence

ODBA_PREDEFINE_SERIALIZABLE

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Methods included from OddbYaml

#to_yaml_properties, #to_yaml_type

Methods included from SequenceObserver

#add_sequence, #empty?, #remove_sequence

Methods included from Language

#all_descriptions, #has_description?, #init, #synonyms, #synonyms=

Methods included from SimpleLanguage

#description, #descriptions, #has_description?, #match, #method_missing, #respond_to?, #search_text, #to_s, #update_values

Methods included from PersistenceMethods

#data_origin, #data_origins, #diff, #init, #nil_if_empty, #parent, #structural_ancestors, #undiffable?, #update_values

Constructor Details

- (AtcClass) initialize(code)

A new instance of AtcClass



38
39
40
41
42
# File 'src/model/atcclass.rb', line 38

def initialize(code)
  @code = code
  @ddds = {}
  super()
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class ODDB::SimpleLanguage

Instance Attribute Details

- (Object) code

Returns the value of attribute code



15
16
17
# File 'src/model/atcclass.rb', line 15

def code
  @code
end

- (Object) ddd_guidelines

Returns the value of attribute ddd_guidelines



16
17
18
# File 'src/model/atcclass.rb', line 16

def ddd_guidelines
  @ddd_guidelines
end

- (Object) descriptions=(value) (writeonly)

use this instead of add_sequence for temporary atc_classes



18
19
20
# File 'src/model/atcclass.rb', line 18

def descriptions=(value)
  @descriptions = value
end

- (Object) guidelines

Returns the value of attribute guidelines



16
17
18
# File 'src/model/atcclass.rb', line 16

def guidelines
  @guidelines
end

- (Object) sequences

Returns the value of attribute sequences



15
16
17
# File 'test/test_model/atcclass.rb', line 15

def sequences
  @sequences
end

Instance Method Details

- (Object) active_packages



43
44
45
# File 'src/model/atcclass.rb', line 43

def active_packages
  @sequences.inject([]) { |inj, seq| inj.concat(seq.public_packages) }
end

- (Object) checkout



51
52
53
54
# File 'src/model/atcclass.rb', line 51

def checkout
  @sequences.dup.each { |seq| seq.atc_class = nil } 
  @sequences.odba_delete
end

- (Object) company_filter_search(company_name)



55
56
57
58
59
60
# File 'src/model/atcclass.rb', line 55

def company_filter_search(company_name)
  filter_proc = Proc.new do |seq|
    ODDB.search_term(seq.company.to_s.downcase).include?(company_name)
  end
  filter filter_proc
end

- (Object) create_ddd(roa)



61
62
63
# File 'src/model/atcclass.rb', line 61

def create_ddd(roa)
  ddds[roa] = DDD.new(roa) 
end

- (Object) create_ddd_guidelines



64
65
66
# File 'src/model/atcclass.rb', line 64

def create_ddd_guidelines
  @ddd_guidelines = Text::Document.new
end

- (Object) create_guidelines



67
68
69
# File 'src/model/atcclass.rb', line 67

def create_guidelines
  @guidelines = Text::Document.new
end

- (Object) ddd(roa)



83
84
85
# File 'src/model/atcclass.rb', line 83

def ddd(roa)
  ddds[roa]
end

- (Object) ddds



86
87
88
# File 'src/model/atcclass.rb', line 86

def ddds
  @ddds ||= {}
end

- (Object) delete_ddd(roa)



89
90
91
92
93
94
# File 'src/model/atcclass.rb', line 89

def delete_ddd(roa)
  if(ddd = @ddds.delete(roa))
    @ddds.odba_isolated_store
    ddd
  end
end

- (Object) filter(filter_proc)



95
96
97
98
99
100
101
# File 'src/model/atcclass.rb', line 95

def filter filter_proc
  atc = self.dup
  atc.sequences = @sequences.select do |seq|
    filter_proc.call seq
  end
  atc
end

- (Boolean) has_ddd?

Returns:

  • (Boolean)


70
71
72
# File 'src/model/atcclass.rb', line 70

def has_ddd?
  !!(@guidelines || @ddd_guidelines || !ddds.empty?)
end

- (Object) level



73
74
75
76
77
78
79
80
81
82
# File 'src/model/atcclass.rb', line 73

def level
  len = @code.length   
  if(len == 7)
    5
  elsif(len > 2)
    len-1
  else
    len
  end
end

- (Object) package_count(generic_type = nil)



46
47
48
49
50
# File 'src/model/atcclass.rb', line 46

def package_count(generic_type=nil)
  @sequences.inject(0) { |inj, seq|
    inj + seq.public_package_count(generic_type)
  }
end

- (Object) packages



102
103
104
# File 'src/model/atcclass.rb', line 102

def packages
  @sequences.collect { |seq| seq.packages.values }.flatten
end

- (Object) parent_code



109
110
111
112
113
114
115
116
# File 'src/model/atcclass.rb', line 109

def parent_code
  case level
  when 2
    @code[0,1]
  when 3, 4, 5
    @code[0,level]
  end
end

- (Object) pointer_descr(key = nil)



117
118
119
# File 'src/model/atcclass.rb', line 117

def pointer_descr(key=nil)
  [super,'(' + @code + ')'].compact.join(' ')
end

- (Object) substances



105
106
107
108
# File 'src/model/atcclass.rb', line 105

def substances
  @sequences.collect { |seq| seq.substances 
  }.flatten.uniq
end