Class: BrowserCrawler::EngineUtilities::LinkInspector

Inherits:
Object
  • Object
show all
Defined in:
lib/browser_crawler/engine_utilities/link_inspector.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(raw_link:, host_name:) ⇒ LinkInspector

Returns a new instance of LinkInspector.



8
9
10
11
12
# File 'lib/browser_crawler/engine_utilities/link_inspector.rb', line 8

def initialize(raw_link:, host_name:)
  @raw_link = raw_link
  @host_name = host_name
  @uri = UrlTools.uri(url: raw_link)
end

Instance Attribute Details

#host_nameObject (readonly)

Returns the value of attribute host_name.



6
7
8
# File 'lib/browser_crawler/engine_utilities/link_inspector.rb', line 6

def host_name
  @host_name
end

Returns the value of attribute raw_link.



6
7
8
# File 'lib/browser_crawler/engine_utilities/link_inspector.rb', line 6

def raw_link
  @raw_link
end

#uriObject (readonly)

Returns the value of attribute uri.



6
7
8
# File 'lib/browser_crawler/engine_utilities/link_inspector.rb', line 6

def uri
  @uri
end

Instance Method Details

#external_url?Boolean

Returns:

  • (Boolean)


14
15
16
# File 'lib/browser_crawler/engine_utilities/link_inspector.rb', line 14

def external_url?
  !internal_url?
end

#full_urlObject



26
27
28
# File 'lib/browser_crawler/engine_utilities/link_inspector.rb', line 26

def full_url
  @full_url ||= UrlTools.full_url(uri: uri)
end

#internal_url?Boolean

Returns:

  • (Boolean)


22
23
24
# File 'lib/browser_crawler/engine_utilities/link_inspector.rb', line 22

def internal_url?
  @internal_url ||= !uri.nil? && uri.host == host_name
end

Returns:

  • (Boolean)


18
19
20
# File 'lib/browser_crawler/engine_utilities/link_inspector.rb', line 18

def link_valid?
  @link_valid ||= !uri.nil? && uri.host && uri.scheme
end