Class: Qa::Authorities::Crossref::GenericAuthority
- Includes:
- WebServiceBase
- Defined in:
- lib/qa/authorities/crossref/generic_authority.rb
Instance Attribute Summary collapse
-
#subauthority ⇒ Object
readonly
Returns the value of attribute subauthority.
Attributes included from WebServiceBase
Instance Method Summary collapse
- #build_query_url(q) ⇒ Object
- #find(id) ⇒ Object
- #find_url(id) ⇒ Object
-
#initialize(subauthority) ⇒ GenericAuthority
constructor
A new instance of GenericAuthority.
- #search(q) ⇒ Object
- #untaint(q) ⇒ Object
Methods included from WebServiceBase
Methods inherited from Base
Constructor Details
#initialize(subauthority) ⇒ GenericAuthority
Returns a new instance of GenericAuthority.
7 8 9 10 |
# File 'lib/qa/authorities/crossref/generic_authority.rb', line 7 def initialize() super() @subauthority = end |
Instance Attribute Details
#subauthority ⇒ Object (readonly)
Returns the value of attribute subauthority.
5 6 7 |
# File 'lib/qa/authorities/crossref/generic_authority.rb', line 5 def @subauthority end |
Instance Method Details
#build_query_url(q) ⇒ Object
26 27 28 29 |
# File 'lib/qa/authorities/crossref/generic_authority.rb', line 26 def build_query_url(q) query = ERB::Util.url_encode(untaint(q)) "http://api.crossref.org/#{}?query=#{query}" end |
#find(id) ⇒ Object
35 36 37 |
# File 'lib/qa/authorities/crossref/generic_authority.rb', line 35 def find(id) json(find_url(id)) end |
#find_url(id) ⇒ Object
39 40 41 |
# File 'lib/qa/authorities/crossref/generic_authority.rb', line 39 def find_url(id) "http://api.crossref.org/#{}/#{id}" end |
#search(q) ⇒ Object
22 23 24 |
# File 'lib/qa/authorities/crossref/generic_authority.rb', line 22 def search(q) (json(build_query_url(q))) end |
#untaint(q) ⇒ Object
31 32 33 |
# File 'lib/qa/authorities/crossref/generic_authority.rb', line 31 def untaint(q) q.gsub(/[^\w\s-]/, '') end |