Class: ConvenientService::Examples::Standard::RequestParams::Utils::URL::Valid

Inherits:
Command
  • Object
show all
Defined in:
lib/convenient_service/examples/standard/request_params/utils/url/valid.rb

Overview

TODO: Use to validate URLs.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Valid

Returns a new instance of Valid.



18
19
20
# File 'lib/convenient_service/examples/standard/request_params/utils/url/valid.rb', line 18

def initialize(url)
  @url = url
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



16
17
18
# File 'lib/convenient_service/examples/standard/request_params/utils/url/valid.rb', line 16

def url
  @url
end

Instance Method Details

#callObject



34
35
36
37
38
39
40
# File 'lib/convenient_service/examples/standard/request_params/utils/url/valid.rb', line 34

def call
  uri = ::URI.parse(url.to_s)

  uri.is_a?(::URI::HTTPS) || uri.is_a?(::URI::HTTP)
rescue ::URI::InvalidURIError
  false
end