Class: Himg::BaseUrl

Inherits:
Object
  • Object
show all
Defined in:
lib/himg/base_url.rb

Instance Method Summary collapse

Constructor Details

#initialize(path_or_url) ⇒ BaseUrl

Returns a new instance of BaseUrl.

Raises:



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_sObject



17
18
19
# File 'lib/himg/base_url.rb', line 17

def to_s
  @url&.to_s
end