Class: ValidatesHost::HostName

Inherits:
Object
  • Object
show all
Defined in:
lib/validates_host/host_name.rb

Instance Method Summary collapse

Constructor Details

#initialize(host_name) ⇒ HostName

Returns a new instance of HostName.



3
4
5
# File 'lib/validates_host/host_name.rb', line 3

def initialize(host_name)
  @host_name = host_name
end

Instance Method Details

#host_nameObject



12
13
14
# File 'lib/validates_host/host_name.rb', line 12

def host_name
  @host_name
end

#valid?Boolean

Returns:

  • (Boolean)


7
8
9
10
# File 'lib/validates_host/host_name.rb', line 7

def valid?
  return true if @host_name.blank?
  @host_name =~ /^[a-z][a-z0-9-]+$/
end