Class: Wovnrb::CustomDomainLang

Inherits:
Object
  • Object
show all
Defined in:
lib/wovnrb/custom_domain/custom_domain_lang.rb

Overview

Represents a custom domain for a given language

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, path, lang) ⇒ CustomDomainLang

Returns a new instance of CustomDomainLang.



6
7
8
9
10
# File 'lib/wovnrb/custom_domain/custom_domain_lang.rb', line 6

def initialize(host, path, lang)
  @host = host
  @path = path.end_with?('/') ? path : "#{path}/"
  @lang = lang
end

Instance Attribute Details

#hostObject

Returns the value of attribute host.



4
5
6
# File 'lib/wovnrb/custom_domain/custom_domain_lang.rb', line 4

def host
  @host
end

#langObject

Returns the value of attribute lang.



4
5
6
# File 'lib/wovnrb/custom_domain/custom_domain_lang.rb', line 4

def lang
  @lang
end

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/wovnrb/custom_domain/custom_domain_lang.rb', line 4

def path
  @path
end

Instance Method Details

#host_and_path_without_trailing_slashObject



17
18
19
20
# File 'lib/wovnrb/custom_domain/custom_domain_lang.rb', line 17

def host_and_path_without_trailing_slash
  host_and_path = @host + @path
  host_and_path.end_with?('/') ? host_and_path.delete_suffix('/') : host_and_path
end

#match?(parsed_uri) ⇒ Boolean

Parameters:

  • uri (Addressable::URI)

Returns:

  • (Boolean)


13
14
15
# File 'lib/wovnrb/custom_domain/custom_domain_lang.rb', line 13

def match?(parsed_uri)
  @host.casecmp?(parsed_uri.host) && path_is_equal_or_subset_of?(@path, parsed_uri.path)
end