Class: RFC::Web::Link::Parsers::Header

Inherits:
Object
  • Object
show all
Defined in:
lib/rfc/web/link/parsers/header.rb

Overview

Parses a header link into a list of records.

Instance Method Summary collapse

Constructor Details

#initialize(pattern: /link/i, list: List.new) ⇒ Header

Returns a new instance of Header.



9
10
11
12
# File 'lib/rfc/web/link/parsers/header.rb', line 9

def initialize pattern: /link/i, list: List.new
  @pattern = pattern
  @list = list
end

Instance Method Details

#call(headers, root_uri:) ⇒ Object



14
15
16
17
# File 'lib/rfc/web/link/parsers/header.rb', line 14

def call headers, root_uri:
  text = headers.find { |key, value| break value if key.match? pattern }
  list.call text, root_uri:
end