Class: PreviewAdd::Names
- Inherits:
-
Object
- Object
- PreviewAdd::Names
- Defined in:
- lib/preview_add/names.rb
Instance Attribute Summary collapse
-
#base_name ⇒ Object
readonly
Returns the value of attribute base_name.
-
#document_root ⇒ Object
readonly
Returns the value of attribute document_root.
-
#domain ⇒ Object
readonly
Returns the value of attribute domain.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#server_name ⇒ Object
readonly
Returns the value of attribute server_name.
Instance Method Summary collapse
-
#initialize(host) ⇒ Names
constructor
A new instance of Names.
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_name ⇒ Object (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_root ⇒ Object (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 |
#domain ⇒ Object (readonly)
Returns the value of attribute domain.
4 5 6 |
# File 'lib/preview_add/names.rb', line 4 def domain @domain end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
4 5 6 |
# File 'lib/preview_add/names.rb', line 4 def host @host end |
#server_name ⇒ Object (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 |