Class: SimpleImagesDownloader::Line

Inherits:
Object
  • Object
show all
Defined in:
lib/simple_images_downloader/line.rb

Overview

Line class Responsible for parsing the string into URI object

Examples:

SimpleImagesDownloader::Line.new('https://example.com/image.jpg').uri
# => #<URI::HTTPS https://example.com/image.jpg>

Instance Method Summary collapse

Constructor Details

#initialize(string) ⇒ Line

Returns a new instance of Line.



12
13
14
# File 'lib/simple_images_downloader/line.rb', line 12

def initialize(string)
  @string = string
end

Instance Method Details

#uriURI

Returns URI object.

Returns:

  • (URI)

    URI object

Raises:

See Also:



20
21
22
23
24
# File 'lib/simple_images_downloader/line.rb', line 20

def uri
  URI.parse(@string)
rescue URI::Error
  raise Errors::BadUrl, @string
end