Class: ValidatesHost::HostName
- Inherits:
-
Object
- Object
- ValidatesHost::HostName
- Defined in:
- lib/validates_host/host_name_validator.rb
Instance Method Summary collapse
- #host_name ⇒ Object
-
#initialize(host_name) ⇒ HostName
constructor
A new instance of HostName.
- #valid? ⇒ Boolean
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_name ⇒ Object
19 20 21 |
# File 'lib/validates_host/host_name_validator.rb', line 19 def host_name @host_name end |
#valid? ⇒ 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 |