Sha256: 9ac7d7c4e46e16972d3f9b2e28772db65cfb7c9bb73d3e1b6d32e5093466209e
Contents?: true
Size: 962 Bytes
Versions: 1
Compression:
Stored size: 962 Bytes
Contents
require 'nokogiri' require 'json' module Qa::Authorities class Tgnlang attr_accessor :response, :raw_response def initialize(q,sub_authority='') self.raw_response = getTgnLang(q) end def getTgnLang(q) str = File.expand_path("../../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 def results self.raw_response end def parse_authority_response self.raw_response end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
qa-0.0.1 | lib/qa/authorities/tgnlang.rb |