Class: Qa::Authorities::Crossref::GenericAuthority
- Inherits:
-
Base
- Object
- Base
- Qa::Authorities::Crossref::GenericAuthority
show all
- Includes:
- WebServiceBase
- Defined in:
- lib/qa/authorities/crossref/generic_authority.rb
Instance Attribute Summary collapse
#raw_response
Instance Method Summary
collapse
#get_json, #json, #response
Methods inherited from Base
#all, #full_record
Constructor Details
Returns a new instance of GenericAuthority.
7
8
9
|
# File 'lib/qa/authorities/crossref/generic_authority.rb', line 7
def initialize(subauthority)
@subauthority = subauthority
end
|
Instance Attribute Details
#subauthority ⇒ Object
Returns the value of attribute subauthority.
5
6
7
|
# File 'lib/qa/authorities/crossref/generic_authority.rb', line 5
def subauthority
@subauthority
end
|
Instance Method Details
#build_query_url(q) ⇒ Object
25
26
27
28
|
# File 'lib/qa/authorities/crossref/generic_authority.rb', line 25
def build_query_url(q)
query = URI.escape(untaint(q))
"http://api.crossref.org/#{subauthority}?query=#{query}"
end
|
#find(id) ⇒ Object
34
35
36
|
# File 'lib/qa/authorities/crossref/generic_authority.rb', line 34
def find(id)
json(find_url(id))
end
|
#find_url(id) ⇒ Object
38
39
40
|
# File 'lib/qa/authorities/crossref/generic_authority.rb', line 38
def find_url(id)
"http://api.crossref.org/#{subauthority}/#{id}"
end
|
#search(q) ⇒ Object
21
22
23
|
# File 'lib/qa/authorities/crossref/generic_authority.rb', line 21
def search(q)
parse_authority_response(json(build_query_url(q)))
end
|
#untaint(q) ⇒ Object
30
31
32
|
# File 'lib/qa/authorities/crossref/generic_authority.rb', line 30
def untaint(q)
q.gsub(/[^\w\s-]/, '')
end
|