class Qa::Authorities::Tgnlang

Public Class Methods

languages() click to toggle source
# File lib/qa/authorities/tgnlang.rb, line 17
def self.languages
  @languages ||=
    begin
      language_filename = File.expand_path("../../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

Public Instance Methods

find(id) click to toggle source
# File lib/qa/authorities/tgnlang.rb, line 34
def find(id)
  id = id.downcase
  Tgnlang.languages.each do |h|
    return h if h["label"].downcase == id
  end
  {}
end
get_tgnlang(q) click to toggle source
# File lib/qa/authorities/tgnlang.rb, line 9
def get_tgnlang(q)
  obj = []
  Tgnlang.languages.each do |h|
    obj.push(h) if h["label"].downcase.start_with?(q.downcase)
  end
  obj
end