Class: Restify::Link
- Inherits:
-
Object
- Object
- Restify::Link
- Defined in:
- lib/restify/link.rb
Overview
A Link represents a single entry from the Link header of a HTTP response.
Constant Summary collapse
- REGEXP_URI =
/<[^>]*>\s*/.freeze
- REGEXP_PAR =
/;\s*\w+\s*=\s*/i.freeze
- REGEXP_QUT =
/"[^"]*"\s*/.freeze
- REGEXP_ARG =
/\w+\s*/i.freeze
Instance Attribute Summary collapse
-
#metadata ⇒ Hash<String, String>
readonly
Link metadata like “rel” if specified.
-
#uri ⇒ String
readonly
Extract URI string.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(uri, metadata = {}) ⇒ Link
constructor
A new instance of Link.
Constructor Details
#initialize(uri, metadata = {}) ⇒ Link
Returns a new instance of Link.
22 23 24 25 |
# File 'lib/restify/link.rb', line 22 def initialize(uri, = {}) @uri = uri @metadata = end |
Instance Attribute Details
#metadata ⇒ Hash<String, String> (readonly)
Link metadata like “rel” if specified.
20 21 22 |
# File 'lib/restify/link.rb', line 20 def @metadata end |
#uri ⇒ String (readonly)
Extract URI string.
14 15 16 |
# File 'lib/restify/link.rb', line 14 def uri @uri end |
Class Method Details
.parse(string) ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/restify/link.rb', line 33 def parse(string) scanner = StringScanner.new(string.strip) catch(:invalid) do return parse_links(scanner) end raise ArgumentError.new \ "Invalid token at #{scanner.pos}: '#{scanner.rest}'" end |