Class: Qa::Authorities::Base
- Inherits:
-
Object
- Object
- Qa::Authorities::Base
- Defined in:
- lib/qa/authorities/base.rb
Instance Attribute Summary collapse
-
#query_url ⇒ Object
Returns the value of attribute query_url.
-
#raw_response ⇒ Object
Returns the value of attribute raw_response.
-
#response ⇒ Object
Returns the value of attribute response.
Class Method Summary collapse
Instance Method Summary collapse
- #get_full_record(id) ⇒ Object
-
#initialize(q, sub_authority = '') ⇒ Base
constructor
A new instance of Base.
- #parse_authority_response ⇒ Object
-
#results ⇒ Object
Parse the result from LOC, and return an JSON array of terms that match the query.
Constructor Details
#initialize(q, sub_authority = '') ⇒ Base
Returns a new instance of Base.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/qa/authorities/base.rb', line 7 def initialize(q, ='') # Implement Me and set self.query_url if self.query_url == nil raise Exception 'query url in your authorities lib is not set (implement in initialize)' end #Default implementation assumed query_url is set http = Curl.get(self.query_url) do |http| http.headers['Accept'] = 'application/json' end self.raw_response = JSON.parse(http.body_str) end |
Instance Attribute Details
#query_url ⇒ Object
Returns the value of attribute query_url.
5 6 7 |
# File 'lib/qa/authorities/base.rb', line 5 def query_url @query_url end |
#raw_response ⇒ Object
Returns the value of attribute raw_response.
5 6 7 |
# File 'lib/qa/authorities/base.rb', line 5 def raw_response @raw_response end |
#response ⇒ Object
Returns the value of attribute response.
5 6 7 |
# File 'lib/qa/authorities/base.rb', line 5 def response @response end |
Class Method Details
.authority_valid?(sub_authority) ⇒ Boolean
22 23 24 |
# File 'lib/qa/authorities/base.rb', line 22 def self.() == nil || .include?() end |
.sub_authorities ⇒ Object
26 27 28 |
# File 'lib/qa/authorities/base.rb', line 26 def self. [] #Overwrite if you have sub_authorities end |
Instance Method Details
#get_full_record(id) ⇒ Object
36 37 38 39 |
# File 'lib/qa/authorities/base.rb', line 36 def get_full_record(id) # implement me {"id"=>id}.to_json end |
#parse_authority_response ⇒ Object
30 31 32 33 34 |
# File 'lib/qa/authorities/base.rb', line 30 def # Overwrite me unless your raw response needs no parsing self.response = self.raw_response end |
#results ⇒ Object
Parse the result from LOC, and return an JSON array of terms that match the query.
42 43 44 |
# File 'lib/qa/authorities/base.rb', line 42 def results self.response.to_json end |