Class: Qa::Authorities::Loc
Instance Attribute Summary
#raw_response
Attributes inherited from Base
#sub_authority
Instance Method Summary
collapse
#authorities, #datatypes, #get_url_for_authority, #preservation, #vocabularies
#get_json, #request_options
Methods inherited from Base
#all, #full_record
Constructor Details
#initialize(*args) ⇒ Loc
Returns a new instance of Loc.
8
9
10
11
12
|
# File 'lib/qa/authorities/loc.rb', line 8
def initialize *args
super
@sub_authority ||= args.first
raise "No sub-authority provided" if sub_authority.nil?
end
|
Instance Method Details
#build_query_url(q) ⇒ Object
23
24
25
26
27
|
# File 'lib/qa/authorities/loc.rb', line 23
def build_query_url q
escaped_query = URI.escape(q)
authority_fragment = get_url_for_authority(sub_authority) + URI.escape(sub_authority)
return "http://id.loc.gov/search/?q=#{escaped_query}&q=#{authority_fragment}&format=json"
end
|
#find(id) ⇒ Object
29
30
31
|
# File 'lib/qa/authorities/loc.rb', line 29
def find id
get_json(find_url(id))
end
|
#find_url(id) ⇒ Object
33
34
35
|
# File 'lib/qa/authorities/loc.rb', line 33
def find_url id
"http://id.loc.gov/authorities/#{@sub_authority}/#{id}.json"
end
|
#search(q) ⇒ Object
18
19
20
21
|
# File 'lib/qa/authorities/loc.rb', line 18
def search q
@raw_response = get_json(build_query_url(q))
parse_authority_response
end
|
#sub_authorities ⇒ Object
14
15
16
|
# File 'lib/qa/authorities/loc.rb', line 14
def sub_authorities
authorities + vocabularies + datatypes + preservation
end
|