Class: Koji::Website

Inherits:
Object
  • Object
show all
Defined in:
lib/koji/website.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(url) ⇒ Website

Returns a new instance of Website.



12
13
14
15
16
# File 'lib/koji/website.rb', line 12

def initialize(url)
  @url = URI(url)
rescue URI::Error => _e
  raise ArgumentError, "#{uri} is not a valid URL."
end

Instance Attribute Details

#urlObject (readonly)

Returns the value of attribute url.



10
11
12
# File 'lib/koji/website.rb', line 10

def url
  @url
end

Instance Method Details

#bodyObject



22
23
24
# File 'lib/koji/website.rb', line 22

def body
  @body ||= response ? response&.body&.to_s : nil
end

#docObject



30
31
32
# File 'lib/koji/website.rb', line 30

def doc
  @doc ||= body ? parse_html(body.to_s) : nil
end

#exceptionObject



34
35
36
# File 'lib/koji/website.rb', line 34

def exception
  @exception || nil
end

#responseObject



18
19
20
# File 'lib/koji/website.rb', line 18

def response
  @response ||= get
end

#sha256Object



26
27
28
# File 'lib/koji/website.rb', line 26

def sha256
  @sha256 ||= body ? Digest::SHA256.hexdigest(body.to_s) : nil
end