Class: Himg::BaseUrl
- Inherits:
-
Object
- Object
- Himg::BaseUrl
- Defined in:
- lib/himg/base_url.rb
Instance Method Summary collapse
-
#initialize(path_or_url) ⇒ BaseUrl
constructor
A new instance of BaseUrl.
- #to_s ⇒ Object
Constructor Details
#initialize(path_or_url) ⇒ BaseUrl
Returns a new instance of BaseUrl.
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/himg/base_url.rb', line 5 def initialize(path_or_url) path_or_url = path_or_url.to_s.strip return if path_or_url&.empty? @url = URI.parse(path_or_url) @url.scheme = "file" unless @url.scheme raise Himg::Error, "Invalid base_url #{path_or_url}" if @url.path.empty? @url.path += "/" unless @url.path.end_with?("/") end |
Instance Method Details
#to_s ⇒ Object
17 18 19 |
# File 'lib/himg/base_url.rb', line 17 def to_s @url&.to_s end |