Class: URLCanonicalize::Client
- Inherits:
-
Object
- Object
- URLCanonicalize::Client
- Defined in:
- lib/url_canonicalize/client.rb
Overview
A reusable canonicalization client. The options are validated and frozen at construction, so one client can be shared safely between threads
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
- #canonicalize(url) ⇒ Object
- #fetch(url) ⇒ Object
-
#initialize(**values) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(**values) ⇒ Client
Returns a new instance of Client.
9 10 11 |
# File 'lib/url_canonicalize/client.rb', line 9 def initialize(**values) @options = URLCanonicalize::Options.new(**values) end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
7 8 9 |
# File 'lib/url_canonicalize/client.rb', line 7 def @options end |
Instance Method Details
#canonicalize(url) ⇒ Object
13 14 15 |
# File 'lib/url_canonicalize/client.rb', line 13 def canonicalize(url) fetch(url).url end |
#fetch(url) ⇒ Object
17 18 19 |
# File 'lib/url_canonicalize/client.rb', line 17 def fetch(url) URLCanonicalize::HTTP.new(url, options: ).fetch end |