Class: Wovnrb::CustomDomainLang
- Inherits:
-
Object
- Object
- Wovnrb::CustomDomainLang
- Defined in:
- lib/wovnrb/custom_domain/custom_domain_lang.rb
Overview
Represents a custom domain for a given language
Instance Attribute Summary collapse
-
#host ⇒ Object
Returns the value of attribute host.
-
#lang ⇒ Object
Returns the value of attribute lang.
-
#path ⇒ Object
Returns the value of attribute path.
Instance Method Summary collapse
- #host_and_path_without_trailing_slash ⇒ Object
-
#initialize(host, path, lang) ⇒ CustomDomainLang
constructor
A new instance of CustomDomainLang.
- #match?(parsed_uri) ⇒ Boolean
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
#host ⇒ Object
Returns the value of attribute host.
4 5 6 |
# File 'lib/wovnrb/custom_domain/custom_domain_lang.rb', line 4 def host @host end |
#lang ⇒ Object
Returns the value of attribute lang.
4 5 6 |
# File 'lib/wovnrb/custom_domain/custom_domain_lang.rb', line 4 def lang @lang end |
#path ⇒ Object
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_slash ⇒ Object
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
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 |