Class: Ezid::Response Private
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Ezid::Response
- Defined in:
- lib/ezid/response.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
A response from the EZID service.
Constant Summary collapse
- SUCCESS =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Success response status
"success"- ERROR =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
Error response status
"error"- IDENTIFIER_RE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/^(doi|ark|urn):[^\s]+/- SHADOW_ARK_RE =
This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.
/\| (ark:[^\s]+)/
Instance Method Summary collapse
-
#content ⇒ Array
private
The body of the response split into: status line and rest of body.
- #cookie ⇒ Object private
-
#error? ⇒ Boolean
private
Whether the outcome was an error.
-
#exception ⇒ Ezid::Error
private
Returns an exception instance if there was an error.
- #id ⇒ Object private
-
#message ⇒ String
private
The EZID status message.
- #metadata ⇒ Object private
-
#outcome ⇒ String
private
The outcome of the request - “success” or “error”.
- #shadow_ark ⇒ Object private
-
#status ⇒ String
private
The response status – “success” or “error”.
-
#status_line ⇒ String
private
The status line of the response.
-
#success? ⇒ Boolean
private
Whether the outcome was a success.
-
#uri_path ⇒ String
private
The URI path of the request.
Instance Method Details
#content ⇒ Array
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The body of the response split into: status line and rest of body
46 47 48 |
# File 'lib/ezid/response.rb', line 46 def content @content ||= body.split(/\r?\n/, 2) end |
#cookie ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
86 87 88 |
# File 'lib/ezid/response.rb', line 86 def self["Set-Cookie"].split(";").first rescue nil end |
#error? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Whether the outcome was an error
64 65 66 |
# File 'lib/ezid/response.rb', line 64 def error? outcome == ERROR end |
#exception ⇒ Ezid::Error
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns an exception instance if there was an error
76 77 78 |
# File 'lib/ezid/response.rb', line 76 def exception @exception ||= (error? && Error.new()) end |
#id ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 |
# File 'lib/ezid/response.rb', line 20 def id @id ||= IDENTIFIER_RE.match()[0] end |
#message ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The EZID status message
58 59 60 |
# File 'lib/ezid/response.rb', line 58 def status.last end |
#metadata ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
28 29 30 |
# File 'lib/ezid/response.rb', line 28 def content[1] end |
#outcome ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The outcome of the request - “success” or “error”
52 53 54 |
# File 'lib/ezid/response.rb', line 52 def outcome status.first end |
#shadow_ark ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
24 25 26 |
# File 'lib/ezid/response.rb', line 24 def shadow_ark @shadow_ark ||= SHADOW_ARK_RE.match()[1] end |
#status ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The response status – “success” or “error”
34 35 36 |
# File 'lib/ezid/response.rb', line 34 def status @status ||= status_line.split(/: /) end |
#status_line ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The status line of the response
40 41 42 |
# File 'lib/ezid/response.rb', line 40 def status_line content[0] end |
#success? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Whether the outcome was a success
70 71 72 |
# File 'lib/ezid/response.rb', line 70 def success? outcome == SUCCESS end |
#uri_path ⇒ String
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
The URI path of the request
82 83 84 |
# File 'lib/ezid/response.rb', line 82 def uri_path __getobj__.uri.path end |