Class: Miteru::Website
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Service
#call, call, #result, result
Constructor Details
#initialize(url, source:) ⇒ Website
Returns a new instance of Website.
17
18
19
20
21
22
|
# File 'lib/miteru/website.rb', line 17
def initialize(url, source:)
super()
@url = url
@source = source
end
|
Instance Attribute Details
#source ⇒ String
11
12
13
|
# File 'lib/miteru/website.rb', line 11
def source
@source
end
|
#url ⇒ String
8
9
10
|
# File 'lib/miteru/website.rb', line 8
def url
@url
end
|
Instance Method Details
#defanged_truncated_url ⇒ Object
51
52
53
|
# File 'lib/miteru/website.rb', line 51
def defanged_truncated_url
truncated_url.to_s.gsub(".", "[.]")
end
|
#index? ⇒ Boolean
32
33
34
|
# File 'lib/miteru/website.rb', line 32
def index?
title.to_s.start_with? "Index of"
end
|
#info ⇒ Object
55
56
57
|
# File 'lib/miteru/website.rb', line 55
def info
"#{defanged_truncated_url} has #{kits.length} kit(s) (Source: #{source})"
end
|
#kits ⇒ Object
28
29
30
|
# File 'lib/miteru/website.rb', line 28
def kits
@kits ||= links.map { |link| Kit.new(link, source:) }.select(&:valid?)
end
|
#kits? ⇒ Boolean
36
37
38
|
# File 'lib/miteru/website.rb', line 36
def kits?
kits.any?
end
|
#links ⇒ Object
40
41
42
|
# File 'lib/miteru/website.rb', line 40
def links
(href_links + possible_file_links).compact.uniq
end
|
#title ⇒ Object
24
25
26
|
# File 'lib/miteru/website.rb', line 24
def title
doc&.at_css("title")&.text
end
|
#truncated_url ⇒ String
47
48
49
|
# File 'lib/miteru/website.rb', line 47
def truncated_url
url.truncate(64)
end
|