Class: Restify::Link

Inherits:
Object
  • Object
show all
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*/
REGEXP_PAR =
/;\s*\w+\s*=\s*/i
REGEXP_QUT =
/"[^"]*"\s*/
REGEXP_ARG =
/\w+\s*/i

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(uri, metadata = {}) ⇒ Link



20
21
22
23
# File 'lib/restify/link.rb', line 20

def initialize(uri,  = {})
  @uri      = uri
   = 
end

Instance Attribute Details

#metadataHash<String, String> (readonly)

Link metadata like “rel” if specified.



18
19
20
# File 'lib/restify/link.rb', line 18

def 
  
end

#uriString (readonly)

Extract URI string.



12
13
14
# File 'lib/restify/link.rb', line 12

def uri
  @uri
end

Class Method Details

.parse(string) ⇒ Object



31
32
33
34
35
36
37
38
39
40
# File 'lib/restify/link.rb', line 31

def parse(string)
  scanner = StringScanner.new(string.strip)

  catch(:invalid) do
    return parse_links(scanner)
  end

  fail ArgumentError,
       "Invalid token at #{scanner.pos}: '#{scanner.rest}'"
end