Class: Qa::Authorities::Tgnlang
- Defined in:
- lib/qa/authorities/tgnlang.rb
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from Base
Class Method Details
.languages ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/qa/authorities/tgnlang.rb', line 20 def self.languages @languages ||= begin language_filename = File.("../../data/TGN_LANGUAGES.xml", __FILE__) lang_array = [] File.open(language_filename) do |f| doc = Nokogiri::XML(f) lang_array = doc.css("Language").map do |lang| id = lang.css("Language_Code").first.text label = lang.css("Language_Name").first.text {"id" => id, "label" => label} end end lang_array end end |
Instance Method Details
#find(id) ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/qa/authorities/tgnlang.rb', line 37 def find(id) id = id.downcase Tgnlang.languages.each do |h| if h["label"].downcase == id return h end end return {} end |
#getTgnLang(q) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/qa/authorities/tgnlang.rb', line 10 def getTgnLang(q) obj = Array.new Tgnlang.languages.each do |h| if h["label"].downcase.start_with?(q.downcase) obj.push(h) end end obj end |
#search(q) ⇒ Object
6 7 8 |
# File 'lib/qa/authorities/tgnlang.rb', line 6 def search(q) getTgnLang(q) end |