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 |
# File 'lib/qa/authorities/crossref/generic_authority.rb', line 7 def initialize() @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
25 26 27 28 |
# File 'lib/qa/authorities/crossref/generic_authority.rb', line 25 def build_query_url(q) query = ERB::Util.url_encode(untaint(q)) "http://api.crossref.org/#{}?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/#{}/#{id}" end |
#search(q) ⇒ Object
21 22 23 |
# File 'lib/qa/authorities/crossref/generic_authority.rb', line 21 def search(q) (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 |