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

Inherits:
Command
  • Object
show all
Defined in:
lib/convenient_service/examples/standard/v1/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.



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

def initialize(url)
  @url = url
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



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

def url
  @url
end

Instance Method Details

#callObject



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

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

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