Class: KDL::Types::IDNHostname
- Inherits:
-
Hostname
- Object
- Value
- Value::Custom
- Hostname
- KDL::Types::IDNHostname
- Defined in:
- lib/kdl/types/hostname.rb,
lib/kdl/types/hostname/validator.rb
Defined Under Namespace
Classes: Validator
Constant Summary
Constants inherited from Value
Instance Attribute Summary collapse
-
#unicode_value ⇒ Object
readonly
Returns the value of attribute unicode_value.
Attributes inherited from Value::Custom
Attributes inherited from Value
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(value, unicode_value:, **kwargs) ⇒ IDNHostname
constructor
A new instance of IDNHostname.
Methods inherited from Value::Custom
Methods inherited from Value
#==, #as_type, from, #inspect, #method_missing, #respond_to_missing?, #stringify_value, #to_s, #to_v2, #version
Constructor Details
#initialize(value, unicode_value:, **kwargs) ⇒ IDNHostname
Returns a new instance of IDNHostname.
22 23 24 25 |
# File 'lib/kdl/types/hostname.rb', line 22 def initialize(value, unicode_value:, **kwargs) super(value, **kwargs) @unicode_value = unicode_value end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class KDL::Value
Instance Attribute Details
#unicode_value ⇒ Object (readonly)
Returns the value of attribute unicode_value.
20 21 22 |
# File 'lib/kdl/types/hostname.rb', line 20 def unicode_value @unicode_value end |
Class Method Details
.call(value, type = 'idn-hostname') ⇒ Object
27 28 29 30 31 32 33 34 |
# File 'lib/kdl/types/hostname.rb', line 27 def self.call(value, type = 'idn-hostname') return nil unless value.is_a? ::KDL::Value::String validator = Validator.new(value.value) raise ArgumentError, "invalid hostname #{value}" unless validator.valid? new(validator.ascii, type: type, unicode_value: validator.unicode) end |