Class: PreviewAdd::Names

Inherits:
Object
  • Object
show all
Defined in:
lib/preview_add/names.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host) ⇒ Names

Returns a new instance of Names.



6
7
8
9
10
11
12
13
14
15
# File 'lib/preview_add/names.rb', line 6

def initialize(host)
  @host = host.dup
  @host.gsub!(/^(https?:\/\/)?(www\.)?/, '')
  
  parts          = @host.split('.')
  @document_root = parts.reverse.join('.')
  @domain        = parts[-2, 2].reverse.join('.')
  @server_name   = parts[0..-2].join('.')
  @base_name     = parts[-2]
end

Instance Attribute Details

#base_nameObject (readonly)

Returns the value of attribute base_name.



4
5
6
# File 'lib/preview_add/names.rb', line 4

def base_name
  @base_name
end

#document_rootObject (readonly)

Returns the value of attribute document_root.



4
5
6
# File 'lib/preview_add/names.rb', line 4

def document_root
  @document_root
end

#domainObject (readonly)

Returns the value of attribute domain.



4
5
6
# File 'lib/preview_add/names.rb', line 4

def domain
  @domain
end

#hostObject (readonly)

Returns the value of attribute host.



4
5
6
# File 'lib/preview_add/names.rb', line 4

def host
  @host
end

#server_nameObject (readonly)

Returns the value of attribute server_name.



4
5
6
# File 'lib/preview_add/names.rb', line 4

def server_name
  @server_name
end