Class: RFC::Web::Link::Encoder
- Inherits:
-
Object
- Object
- RFC::Web::Link::Encoder
- Defined in:
- lib/rfc/web/link/encoder.rb
Overview
A HTTP header field encoder which adheres to RFC 8187.
Instance Method Summary collapse
- #call(text) ⇒ Object
-
#initialize(pattern: /[^0-9a-zA-Z!\#$&+\-.^_`|~]/) ⇒ Encoder
constructor
A new instance of Encoder.
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 |