Class: RFC::Web::Link::Encoder

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

Overview

A HTTP header field encoder which adheres to RFC 8187.

Instance Method Summary collapse

Constructor Details

#initialize(pattern: /[^0-9a-zA-Z!\#$&+\-.^_`|~]/) ⇒ Encoder

Returns a new instance of Encoder.



8
9
10
# File 'lib/rfc/web/link/encoder.rb', line 8

def initialize pattern: /[^0-9a-zA-Z!\#$&+\-.^_`|~]/
  @pattern = pattern
end

Instance Method Details

#call(text) ⇒ Object



12
# File 'lib/rfc/web/link/encoder.rb', line 12

def call(text) = text.match?(pattern) ? convert_characters(text).join : text