Class: Ress::Subdomain::RegexpSubdomain
- Inherits:
-
Object
- Object
- Ress::Subdomain::RegexpSubdomain
- Defined in:
- lib/ress/subdomain.rb
Overview
The main inspiration for this class is to match xip.io subdomains for many devs working in development mode with the same configuration.
Instance Attribute Summary collapse
-
#subdomain ⇒ Object
readonly
Returns the value of attribute subdomain.
Instance Method Summary collapse
-
#initialize(subdomain) ⇒ RegexpSubdomain
constructor
A new instance of RegexpSubdomain.
- #matches?(subdomain) ⇒ Boolean
- #url(protocol, fullpath, subdomain) ⇒ Object
Constructor Details
#initialize(subdomain) ⇒ RegexpSubdomain
Returns a new instance of RegexpSubdomain.
56 57 58 |
# File 'lib/ress/subdomain.rb', line 56 def initialize(subdomain) @subdomain = subdomain end |
Instance Attribute Details
#subdomain ⇒ Object (readonly)
Returns the value of attribute subdomain.
54 55 56 |
# File 'lib/ress/subdomain.rb', line 54 def subdomain @subdomain end |
Instance Method Details
#matches?(subdomain) ⇒ Boolean
60 61 62 |
# File 'lib/ress/subdomain.rb', line 60 def matches?(subdomain) self.subdomain =~ subdomain end |
#url(protocol, fullpath, subdomain) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/ress/subdomain.rb', line 64 def url(protocol, fullpath, subdomain) fullpath = fullpath[(subdomain.length + 1)..-1] unless subdomain.empty? begin return build_url(protocol, subdomain, fullpath) if matches?(subdomain) end while( subdomain.slice!(/^[^\.]+\.?/) ) end |