Module: URI::Subdomain
- Defined in:
- lib/uri/subdomain.rb
Constant Summary collapse
- VERSION =
"0.0.4"
Instance Method Summary collapse
Instance Method Details
#domain ⇒ Object
7 8 9 |
# File 'lib/uri/subdomain.rb', line 7 def domain host.split('.').last(2).join('.') if host end |
#domain=(domain) ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/uri/subdomain.rb', line 11 def domain= domain if subdomain.nil? self.host = domain else self.host = "#{subdomain}.#{domain}" end end |
#subdomain ⇒ Object
19 20 21 22 23 |
# File 'lib/uri/subdomain.rb', line 19 def subdomain return nil if host.nil? subdomain = host.split('.').tap(&:pop).tap(&:pop).join('.') subdomain == "" ? nil : subdomain end |
#subdomain=(subdomain) ⇒ Object
25 26 27 |
# File 'lib/uri/subdomain.rb', line 25 def subdomain= subdomain self.host = "#{subdomain}.#{domain}" end |