Class: ODDB::IndexTherapeuticus

Inherits:
Object
  • Object
show all
Includes:
ODBA::Persistable, SimpleLanguage
Defined in:
src/model/index_therapeuticus.rb

Constant Summary

ODBA_SERIALIZABLE =
['@descriptions']

Constants included from Persistence

ODBA_PREDEFINE_SERIALIZABLE

Instance Attribute Summary (collapse)

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from SimpleLanguage

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

Methods included from PersistenceMethods

#checkout, #data_origin, #data_origins, #diff, #init, #nil_if_empty, #pointer_descr, #structural_ancestors, #undiffable?, #update_values

Constructor Details

- (IndexTherapeuticus) initialize(code)

A new instance of IndexTherapeuticus



39
40
41
# File 'src/model/index_therapeuticus.rb', line 39

def initialize code
  @code = self.class.normalize_code code
end

Dynamic Method Handling

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

Instance Attribute Details

- (Object) code (readonly)

Returns the value of attribute code



13
14
15
# File 'src/model/index_therapeuticus.rb', line 13

def code
  @code
end

- (Object) comment (readonly)

Returns the value of attribute comment



13
14
15
# File 'src/model/index_therapeuticus.rb', line 13

def comment
  @comment
end

- (Object) limitation_text (readonly)

Returns the value of attribute limitation_text



13
14
15
# File 'src/model/index_therapeuticus.rb', line 13

def limitation_text
  @limitation_text
end

- (Object) source

Returns the value of attribute source



14
15
16
# File 'src/model/index_therapeuticus.rb', line 14

def source
  @source
end

Class Method Details

+ (Object) find_by_code(code) Also known as: __find_by_normalized_code__



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

def find_by_code(code)
  __find_by_normalized_code__ normalize_code(code)
end

+ (Object) normalize_code(code)



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'src/model/index_therapeuticus.rb', line 21

def normalize_code(code)
  if code && nonempty = code.to_s[/.*\d/u]
    parts = nonempty.split('.', 3)
    if((str = parts.last) && str.length == 1)
      str << '0'
    end
    parts.collect! { |part| part.to_i }
    norm = ''
    while((part = parts.shift) && part > 0)
      norm << sprintf('%02i.', part)
    end
    norm
  end
end

+ (Object) null



35
36
37
# File 'src/model/index_therapeuticus.rb', line 35

def null
  @null ||= new nil
end

Instance Method Details

- (Object) create_comment



42
43
44
# File 'src/model/index_therapeuticus.rb', line 42

def create_comment
  @comment = Text::Document.new
end

- (Object) create_limitation_text



45
46
47
# File 'src/model/index_therapeuticus.rb', line 45

def create_limitation_text
  @limitation_text = LimitationText.new
end

- (Object) delete_comment



48
49
50
51
52
53
# File 'src/model/index_therapeuticus.rb', line 48

def delete_comment
  if(cm = @comment)
    @comment = nil
    cm
  end
end

- (Object) delete_limitation_text



54
55
56
57
58
59
# File 'src/model/index_therapeuticus.rb', line 54

def delete_limitation_text
  if(lt = @limitation_text)
    @limitation_text = nil
    lt
  end
end

- (Object) parent



60
61
62
63
64
# File 'src/model/index_therapeuticus.rb', line 60

def parent
  if parent_code = @code[/.+(?=\d{2}.?)/u]
    IndexTherapeuticus.find_by_code parent_code
  end
end