Class: KDL::Types::Hostname

Inherits:
Value
  • Object
show all
Defined in:
lib/kdl/types/hostname.rb,
lib/kdl/types/hostname/validator.rb

Direct Known Subclasses

IDNHostname

Defined Under Namespace

Classes: Validator

Constant Summary

Constants inherited from Value

Value::Null

Instance Attribute Summary

Attributes inherited from Value

#format, #type, #value

Class Method Summary collapse

Methods inherited from Value

#as_type, from, #initialize, #stringify_value, #to_s

Constructor Details

This class inherits a constructor from KDL::Value

Class Method Details

.call(value, type = 'hostname') ⇒ Object

Raises:

  • (ArgumentError)


6
7
8
9
10
11
12
13
# File 'lib/kdl/types/hostname.rb', line 6

def self.call(value, type = 'hostname')
  return nil unless value.is_a? ::KDL::Value::String

  validator = Validator.new(value.value)
  raise ArgumentError, "invalid hostname #{value}" unless validator.valid?

  new(value.value, type: type)
end