Module: LinkHeaderParser

Defined in:
lib/link-header-parser.rb,
lib/link_header_parser/version.rb,
lib/link_header_parser/link_header.rb,
lib/link_header_parser/link_header_parameter.rb,
lib/link_header_parser/link_headers_collection.rb

Defined Under Namespace

Classes: LinkHeader, LinkHeaderParameter, LinkHeadersCollection

Constant Summary collapse

VERSION =
"6.0.1"

Class Method Summary collapse

Class Method Details

.parse(*headers, base:) ⇒ LinkHeadersCollection

Parse an array of HTTP Link headers.

Convenience method for LinkHeaderParser::LinkHeadersCollection#initialize.

Examples:

require "net/http"

url = "https://sixtwothree.org"
link_headers = Net::HTTP.get_response(URI.parse(url)).get_fields("Link")

LinkHeaderParser.parse(link_headers, base: url)

Parameters:

  • headers (Array<String, #to_str>)
  • base (String, #to_str)

Returns:



27
28
29
# File 'lib/link-header-parser.rb', line 27

def self.parse(*headers, base:)
  LinkHeadersCollection.new(*headers, base: base)
end