Class: CommonLib::TranslationTable

Inherits:
Object
  • Object
show all
Defined in:
lib/common_lib/translation_table.rb

Direct Known Subclasses

ADNA, PADK, POSNEG, YNDK, YNODK, YNORDK, YNRDK

Class Method Summary collapse

Class Method Details

.[](key = nil) ⇒ Object



3
4
5
# File 'lib/common_lib/translation_table.rb', line 3

def self.[](key=nil)
	short(key) || short(key.to_s.downcase) || value(key) || nil
end

.selector_optionsObject

[‘Yes’,1],,[“Don’t Know”,999]


17
18
19
20
# File 'lib/common_lib/translation_table.rb', line 17

def self.selector_options
#		@@selector_options ||= table.collect{|x| [x[:long],x[:value]] }
	table.collect{|x| [x[:long],x[:value]] }
end

.short(key) ⇒ Object



24
25
26
27
# File 'lib/common_lib/translation_table.rb', line 24

def self.short(key)
	index = table.find_index{|x| x[:short] == key.to_s }
	( index.nil? ) ? nil : table[index][:value]
end

.tableObject



36
37
38
# File 'lib/common_lib/translation_table.rb', line 36

def self.table
	[]
end

.valid_valuesObject

1,2,999


11
12
13
14
# File 'lib/common_lib/translation_table.rb', line 11

def self.valid_values
#		@@valid_values ||= table.collect{ |x| x[:value] }
	table.collect{ |x| x[:value] }
end

.value(key) ⇒ Object



29
30
31
32
33
34
# File 'lib/common_lib/translation_table.rb', line 29

def self.value(key)
#	used in testing and breaks in ruby 1.9.3 so next line is NEEDED!
return nil if key == :nil
	index = table.find_index{|x| x[:value] == key.to_i }
	( index.nil? ) ? nil : table[index][:long] 
end