Module: ODDB::SimpleLanguage

Includes:
Persistence
Included in:
Analysis::Position, IndexTherapeuticus, Language, LimitationText, Migel::Group, Migel::Product, Migel::Subgroup, Text::Document, View::Drugs::TestResultList::StubLimitationText
Defined in:
src/util/language.rb,
ext/export/src/oddb_yaml.rb

Defined Under Namespace

Classes: Descriptions

Constant Summary

Constants included from Persistence

ODBA_PREDEFINE_SERIALIZABLE

Instance Method Summary (collapse)

Methods included from Persistence

#initialize

Methods included from PersistenceMethods

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

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

- (Object) method_missing(symbol, *args, &block)



39
40
41
42
43
44
45
46
# File 'src/util/language.rb', line 39

def method_missing(symbol, *args, &block)
  language = symbol.to_s
  if(language.length == 2)
    description(language)
  else
    super
  end
end

Instance Method Details

- (Object) description(key = nil) Also known as: pointer_descr



27
28
29
# File 'src/util/language.rb', line 27

def description(key=nil)
  descriptions[key.to_s] || descriptions.first
end

- (Object) descriptions



30
31
32
# File 'src/util/language.rb', line 30

def descriptions
  @descriptions ||= Descriptions.new
end

- (Boolean) has_description?(description)

Returns:

  • (Boolean)


33
34
35
# File 'src/util/language.rb', line 33

def has_description?(description)
  descriptions.has_value?(description)
end

- (Object) match(pattern)



36
37
38
# File 'src/util/language.rb', line 36

def match(pattern)
  descriptions.values.any? { |desc| pattern.match(desc) }
end

- (Boolean) respond_to?(symbol, *args)

Returns:

  • (Boolean)


47
48
49
# File 'src/util/language.rb', line 47

def respond_to?(symbol, *args)
  symbol.to_s.length == 2 || super
end

- (Object) search_text(language)



50
51
52
# File 'src/util/language.rb', line 50

def search_text(language)
  ODDB.search_term(self.send(language).to_s)
end

- (Object) to_s Also known as: name



53
54
55
56
57
58
59
# File 'src/util/language.rb', line 53

def to_s
  if descriptions.empty?
    ''
  else
    descriptions.first.to_s
  end
end

- (Object) update_values(values, origin = nil)



60
61
62
63
64
65
66
67
68
# File 'src/util/language.rb', line 60

def update_values(values, origin=nil)
  values = values.dup
  descr = values.keys.inject({}) { |inj, key|
    inj.store(key.to_s, values.delete(key)) if(key.to_s.length==2)
    inj
  }
  descriptions.update_values(descr)
  super(values, origin)
end