Class: URLCanonicalize::Client

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

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

#optionsObject (readonly)

Returns the value of attribute options.



7
8
9
# File 'lib/url_canonicalize/client.rb', line 7

def options
  @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: options).fetch
end