Class: HandleSystem::Client
- Inherits:
-
Object
- Object
- HandleSystem::Client
- Defined in:
- lib/handle_system/client.rb
Overview
Handle System client
Instance Method Summary collapse
-
#create(handle, url, email = nil, hs_admin = nil) ⇒ string
Create a new handle.
-
#delete(handle) ⇒ Boolean
Delete a handle.
-
#get(handle) ⇒ HandleSystem::Record
Return the full record for a handle.
-
#initialize(server, hs_admin, priv_key_path, pass_phrase = nil) ⇒ Client
constructor
New Handle System client.
-
#update(handle, url, email = nil, hs_admin = nil) ⇒ string
Update an existing handle.
Constructor Details
#initialize(server, hs_admin, priv_key_path, pass_phrase = nil) ⇒ Client
New Handle System client
18 19 20 21 |
# File 'lib/handle_system/client.rb', line 18 def initialize(server, hs_admin, priv_key_path, pass_phrase = nil) @http_client = HttpClient.new(server, hs_admin, priv_key_path, pass_phrase) @handle_base = 'http://hdl.handle.net/' end |
Instance Method Details
#create(handle, url, email = nil, hs_admin = nil) ⇒ string
Create a new handle
33 34 35 |
# File 'lib/handle_system/client.rb', line 33 def create(handle, url, email = nil, hs_admin = nil) set_record(handle, url, email, hs_admin, false) end |
#delete(handle) ⇒ Boolean
Delete a handle
72 73 74 75 |
# File 'lib/handle_system/client.rb', line 72 def delete(handle) json = @http_client.delete('/handles/' + handle) return true if json['responseCode'] == 1 end |
#get(handle) ⇒ HandleSystem::Record
Return the full record for a handle
60 61 62 63 |
# File 'lib/handle_system/client.rb', line 60 def get(handle) json = @http_client.get('/handles/' + handle) Record.new.from_json(json) end |
#update(handle, url, email = nil, hs_admin = nil) ⇒ string
Update an existing handle
Will create a new handle if no record already exists
49 50 51 |
# File 'lib/handle_system/client.rb', line 49 def update(handle, url, email = nil, hs_admin = nil) set_record(handle, url, email, hs_admin, true) end |