Class: ValidatesHost::HostName

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

Instance Method Summary collapse

Constructor Details

#initialize(host_name) ⇒ HostName

Returns a new instance of HostName.



10
11
12
# File 'lib/validates_host/host_name_validator.rb', line 10

def initialize(host_name)
  @host_name = host_name
end

Instance Method Details

#host_nameObject



19
20
21
# File 'lib/validates_host/host_name_validator.rb', line 19

def host_name
  @host_name
end

#valid?Boolean

Returns:

  • (Boolean)


14
15
16
17
# File 'lib/validates_host/host_name_validator.rb', line 14

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