Class: Qa::Authorities::Tgnlang
- Inherits:
-
Object
- Object
- Qa::Authorities::Tgnlang
- Defined in:
- lib/qa/authorities/tgnlang.rb
Instance Attribute Summary collapse
-
#raw_response ⇒ Object
Returns the value of attribute raw_response.
-
#response ⇒ Object
Returns the value of attribute response.
Instance Method Summary collapse
- #getTgnLang(q) ⇒ Object
-
#initialize(q, sub_authority = '') ⇒ Tgnlang
constructor
A new instance of Tgnlang.
- #parse_authority_response ⇒ Object
- #results ⇒ Object
Constructor Details
#initialize(q, sub_authority = '') ⇒ Tgnlang
Returns a new instance of Tgnlang.
7 8 9 |
# File 'lib/qa/authorities/tgnlang.rb', line 7 def initialize(q,='') self.raw_response = getTgnLang(q) end |
Instance Attribute Details
#raw_response ⇒ Object
Returns the value of attribute raw_response.
6 7 8 |
# File 'lib/qa/authorities/tgnlang.rb', line 6 def raw_response @raw_response end |
#response ⇒ Object
Returns the value of attribute response.
6 7 8 |
# File 'lib/qa/authorities/tgnlang.rb', line 6 def response @response end |
Instance Method Details
#getTgnLang(q) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/qa/authorities/tgnlang.rb', line 11 def getTgnLang(q) str = File.("../../data/TGN_LANGUAGES.xml", __FILE__) doc = Nokogiri::XML(File.open(str)) size = doc.css("Language_Name").size i=0 lang_array = Array.new while i < size do lang_hash = Hash.new lang_hash["id"] = doc.css("Language_Code")[i].text lang_hash["label"] = doc.css("Language_Name")[i].text lang_array.push(lang_hash) i+=1 end obj = Array.new lang_array.each do |h| if h["label"].downcase.start_with?(q.downcase) obj.push(h) end end obj.to_json end |
#parse_authority_response ⇒ Object
36 37 38 |
# File 'lib/qa/authorities/tgnlang.rb', line 36 def self.raw_response end |
#results ⇒ Object
33 34 35 |
# File 'lib/qa/authorities/tgnlang.rb', line 33 def results self.raw_response end |