Class: WebInspector::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/web_inspector/request.rb

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Request

Returns a new instance of Request.



7
8
9
# File 'lib/web_inspector/request.rb', line 7

def initialize(url)
  @url = url
end

Instance Method Details

#domainObject



19
20
21
# File 'lib/web_inspector/request.rb', line 19

def domain
  suffix_domain
end

#error_messageObject



41
42
43
44
45
# File 'lib/web_inspector/request.rb', line 41

def error_message
  return nil if valid?

  'Invalid URL: Unable to parse the provided URL'
end

#hostObject



15
16
17
# File 'lib/web_inspector/request.rb', line 15

def host
  uri.host
end

#portObject



27
28
29
# File 'lib/web_inspector/request.rb', line 27

def port
  URI(normalized_uri).port
end

#schemeObject



23
24
25
# File 'lib/web_inspector/request.rb', line 23

def scheme
  uri.scheme
end

#ssl?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/web_inspector/request.rb', line 37

def ssl?
  scheme == 'https'
end

#urlObject



11
12
13
# File 'lib/web_inspector/request.rb', line 11

def url
  normalized_uri
end

#valid?Boolean

Returns:

  • (Boolean)


31
32
33
34
35
# File 'lib/web_inspector/request.rb', line 31

def valid?
  !uri.nil? && !uri.host.nil?
rescue StandardError
  false
end