Class: Koji::Website
- Inherits:
-
Object
- Object
- Koji::Website
- Defined in:
- lib/koji/website.rb
Instance Attribute Summary collapse
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Instance Method Summary collapse
- #body ⇒ Object
- #doc ⇒ Object
- #exception ⇒ Object
-
#initialize(url) ⇒ Website
constructor
A new instance of Website.
- #response ⇒ Object
- #sha256 ⇒ Object
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
#url ⇒ Object (readonly)
Returns the value of attribute url.
10 11 12 |
# File 'lib/koji/website.rb', line 10 def url @url end |
Instance Method Details
#body ⇒ Object
22 23 24 |
# File 'lib/koji/website.rb', line 22 def body @body ||= response ? response&.body&.to_s : nil end |
#doc ⇒ Object
30 31 32 |
# File 'lib/koji/website.rb', line 30 def doc @doc ||= body ? parse_html(body.to_s) : nil end |
#exception ⇒ Object
34 35 36 |
# File 'lib/koji/website.rb', line 34 def exception @exception || nil end |
#response ⇒ Object
18 19 20 |
# File 'lib/koji/website.rb', line 18 def response @response ||= get end |
#sha256 ⇒ Object
26 27 28 |
# File 'lib/koji/website.rb', line 26 def sha256 @sha256 ||= body ? Digest::SHA256.hexdigest(body.to_s) : nil end |