Class: Miteru::Website
Instance Attribute Summary collapse
Instance Method Summary
collapse
#decoded_url, #defanged_truncated_url, #truncated_url
Methods inherited from Service
#call, call, #result, result
Constructor Details
#initialize(url, source:) ⇒ Website
Returns a new instance of Website.
19
20
21
22
23
24
|
# File 'lib/miteru/website.rb', line 19
def initialize(url, source:)
super()
@url = url
@source = source
end
|
Instance Attribute Details
#source ⇒ String
13
14
15
|
# File 'lib/miteru/website.rb', line 13
def source
@source
end
|
#url ⇒ String
10
11
12
|
# File 'lib/miteru/website.rb', line 10
def url
@url
end
|
Instance Method Details
#index? ⇒ Boolean
34
35
36
|
# File 'lib/miteru/website.rb', line 34
def index?
title.to_s.start_with? "Index of"
end
|
#info ⇒ Object
46
47
48
|
# File 'lib/miteru/website.rb', line 46
def info
"#{defanged_truncated_url} has #{kits.length} kit(s) (Source: #{source})"
end
|
#kits ⇒ Object
30
31
32
|
# File 'lib/miteru/website.rb', line 30
def kits
@kits ||= links.map { |link| Kit.new(link, source:) }.select(&:valid?)
end
|
#kits? ⇒ Boolean
38
39
40
|
# File 'lib/miteru/website.rb', line 38
def kits?
kits.any?
end
|
#links ⇒ Object
42
43
44
|
# File 'lib/miteru/website.rb', line 42
def links
(href_links + possible_file_links).compact.uniq
end
|
#title ⇒ Object
26
27
28
|
# File 'lib/miteru/website.rb', line 26
def title
doc&.at_css("title")&.text
end
|