class Ryodo::Domain

Public Class Methods

new(domainStr) click to toggle source
# File lib/ryodo/domain.rb, line 29
def initialize(domainStr)
  fail TypeError, "Not a valid domain string!" unless domainStr.is_a?(String)
  @domain_string = DomainString.new domainStr.downcase
  parse_domain_string
  retrieve_domain_parts
end

Public Instance Methods

domain() click to toggle source
# File lib/ryodo/domain.rb, line 41
def domain
  DomainString.new(@domain) if @domain
end
Also aliased as: registered_domain, regdomain
fqdn() click to toggle source
# File lib/ryodo/domain.rb, line 57
def fqdn
  DomainString.new("#{self}.")
end
inspect() click to toggle source
# File lib/ryodo/domain.rb, line 70
def inspect
  @domain_string.inspect
end
is_valid?()
Alias for: valid?
method_missing(name, *args, &block) click to toggle source

pass all missings to @domain_string (String class)

# File lib/ryodo/domain.rb, line 75
def method_missing(name, *args, &block)
  @domain_string.send(name, *args, &block)
end
regdomain()
Alias for: domain
registered_domain()
Alias for: domain
registered_name()
Alias for: second_level
second_level() click to toggle source
# File lib/ryodo/domain.rb, line 47
def second_level
  DomainString.new(@secondary) if @secondary
end
Also aliased as: sld, registered_name
send(symbol, *args) click to toggle source

explicit definition of class’ send

# File lib/ryodo/domain.rb, line 80
def send(symbol, *args)
  __send__(symbol, *args)
end
sld()
Alias for: second_level
subdomain() click to toggle source
# File lib/ryodo/domain.rb, line 53
def subdomain
  DomainString.new(@subdomain) if @subdomain
end
suffix() click to toggle source
# File lib/ryodo/domain.rb, line 36
def suffix
  DomainString.new(@suffix) if @suffix
end
Also aliased as: tld
tld()
Alias for: suffix
to_s() click to toggle source
# File lib/ryodo/domain.rb, line 66
def to_s
  @domain_string
end
valid?() click to toggle source
# File lib/ryodo/domain.rb, line 61
def valid?
  @suffix && @secondary && true
end
Also aliased as: is_valid?

Private Instance Methods

parse_domain_string() click to toggle source
# File lib/ryodo/domain.rb, line 86
def parse_domain_string
  no_leading_dot     = @domain_string[0] != "."
  @_parts            = Ryodo::Parser.run(@domain_string)
  @_no_dot_but_parts = no_leading_dot && @_parts
end
retrieve_domain() click to toggle source
# File lib/ryodo/domain.rb, line 103
def retrieve_domain
  @domain = (@_parts[0] + @_parts[1]).reverse.join(".") if @_no_dot_but_parts && !@_parts[1].empty?
end
retrieve_domain_parts() click to toggle source
# File lib/ryodo/domain.rb, line 92
def retrieve_domain_parts
  retrieve_suffix
  retrieve_domain
  retrieve_secondary
  retrieve_subdomain
end
retrieve_secondary() click to toggle source
# File lib/ryodo/domain.rb, line 107
def retrieve_secondary
  @secondary = @_parts[1].first if @_no_dot_but_parts && !@_parts[1].empty?
end
retrieve_subdomain() click to toggle source
# File lib/ryodo/domain.rb, line 111
def retrieve_subdomain
  @subdomain = (@_parts[2]).reverse.join(".") if @_no_dot_but_parts && !@_parts[2].empty?
end
retrieve_suffix() click to toggle source
# File lib/ryodo/domain.rb, line 99
def retrieve_suffix
  @suffix = @_parts[0].reverse.join(".") if @_no_dot_but_parts
end