Class: KDL::Types::Hostname

Inherits:
Value::Custom 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::Custom

#oriinal_value

Attributes inherited from Value

#format, #type, #value

Class Method Summary collapse

Methods inherited from Value::Custom

#to_v1, #to_v2, #version

Methods inherited from Value

#==, #as_type, from, #initialize, #inspect, #method_missing, #respond_to_missing?, #stringify_value, #to_s, #to_v2, #version

Constructor Details

This class inherits a constructor from KDL::Value

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class KDL::Value

Class Method Details

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

Raises:

  • (ArgumentError)


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

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