Class: Qa::Authorities::Tgnlang
- Inherits:
-
Object
- Object
- Qa::Authorities::Tgnlang
- Extended by:
- Deprecation
- Defined in:
- lib/qa/authorities/tgnlang.rb
Instance Attribute Summary collapse
-
#response ⇒ Object
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
- #full_record(id, sub_authority) ⇒ Object
- #get_full_record(id, sub_authority) ⇒ Object
- #getTgnLang(q) ⇒ Object
-
#initialize ⇒ Tgnlang
constructor
A new instance of Tgnlang.
- #results ⇒ Object
- #search(q, sub_authority = '') ⇒ Object
Constructor Details
#initialize ⇒ Tgnlang
Returns a new instance of Tgnlang.
8 9 |
# File 'lib/qa/authorities/tgnlang.rb', line 8 def initialize end |
Instance Attribute Details
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/qa/authorities/tgnlang.rb', line 5 def response @response end |
Class Method Details
.languages ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/qa/authorities/tgnlang.rb', line 25 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
#full_record(id, sub_authority) ⇒ Object
51 52 53 54 55 56 57 58 59 |
# File 'lib/qa/authorities/tgnlang.rb', line 51 def full_record(id, ) id = id.downcase Tgnlang.languages.each do |h| if h["label"].downcase == id return h end end return {} end |
#get_full_record(id, sub_authority) ⇒ Object
46 47 48 49 |
# File 'lib/qa/authorities/tgnlang.rb', line 46 def get_full_record(id, ) Deprecation.warn(Tgnlang, "get_full_record is deprecated and will be removed in 0.1.0. Use full_record instead", caller) full_record(id, ) end |
#getTgnLang(q) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/qa/authorities/tgnlang.rb', line 15 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 |
#results ⇒ Object
42 43 44 |
# File 'lib/qa/authorities/tgnlang.rb', line 42 def results self.response end |
#search(q, sub_authority = '') ⇒ Object
11 12 13 |
# File 'lib/qa/authorities/tgnlang.rb', line 11 def search(q, ='') self.response = getTgnLang(q) end |