Class: Adomain
- Inherits:
-
Object
- Object
- Adomain
- Defined in:
- lib/adomain.rb,
lib/adomain/version.rb
Constant Summary collapse
- ADDRESSABLE_WARNING =
%{ WARNING: breaking change planned: Adomain will catch Addressable::URI::InvalidURIError. This error will be caught in version 0.2. Any code relying on the error will break. }.gsub(/\s+/, ' ').strip
- VERSION =
"0.1.2"
Class Method Summary collapse
-
.[](string, domain = false, www = false) ⇒ Object
-
is a convenience method to subdomain the URL, or optionally domain or subdomain_www.
-
.domain(string, domain = true, www = false) ⇒ Object
domain is the base method for only the domain from parse_for_domain Adomain.domain “www.xyz.com” # => “xyz.com” Adomain.domain “abc.xyz.com” # => “xyz.com” Adomain.domain “xyz.com” # => “xyz.com”.
-
.subdomain(string, www = false) ⇒ Object
subdomain is a convenience method for the domain with any subdomain except “www” from parse_for_domain Adomain.subdomain “www.xyz.com” # => “xyz.com” Adomain.subdomain “abc.xyz.com” # => “abc.xyz.com” Adomain.subdomain “xyz.com” # => “xyz.com”.
-
.subdomain_www(string) ⇒ Object
subdomain_www is a convenience method for the domain with any subdomain including “www” from parse_for_domain Adomain.subdomain_www “www.xyz.com” # => “www.xyz.com” Adomain.subdomain_www “abc.xyz.com” # => “abc.xyz.com” Adomain.subdomain_www “xyz.com” # => “xyz.com”.
Class Method Details
.[](string, domain = false, www = false) ⇒ Object
-
is a convenience method to subdomain the URL,
or optionally domain or subdomain_www.
Adomain["http://abc.xyz.com"] # => "abc.xyz.com"
Adomain["http://abc.xyz.com", true] # => "xyz.com"
Adomain["http://www.xyz.com", false, true] # => "www.xyz.com"
Adomain["http://abc.xyz.com", false, false] # => "abc.xyz.com"
21 22 23 |
# File 'lib/adomain.rb', line 21 def [](string, domain = false, www = false) domain(string, domain, www) end |
.domain(string, domain = true, www = false) ⇒ Object
29 30 31 32 |
# File 'lib/adomain.rb', line 29 def domain(string, domain = true, www = false) opts = { :keep_www => www, :strip_subdomain => domain } parse_for_domain(string, opts) end |
.subdomain(string, www = false) ⇒ Object
39 40 41 |
# File 'lib/adomain.rb', line 39 def subdomain(string, www = false) domain(string, false, www) end |
.subdomain_www(string) ⇒ Object
48 49 50 |
# File 'lib/adomain.rb', line 48 def subdomain_www(string) subdomain(string, true) end |