Class: 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
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(value, unicode_value:, **kwargs) ⇒ IDNHostname
constructor
A new instance of IDNHostname.
Methods inherited from Value
#as_type, from, #stringify_value, #to_s
Constructor Details
#initialize(value, unicode_value:, **kwargs) ⇒ IDNHostname
Returns a new instance of IDNHostname.
20 21 22 23 |
# File 'lib/kdl/types/hostname.rb', line 20 def initialize(value, unicode_value:, **kwargs) super(value, **kwargs) @unicode_value = unicode_value end |
Instance Attribute Details
#unicode_value ⇒ Object (readonly)
Returns the value of attribute unicode_value.
18 19 20 |
# File 'lib/kdl/types/hostname.rb', line 18 def unicode_value @unicode_value end |
Class Method Details
.call(value, type = 'idn-hostname') ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/kdl/types/hostname.rb', line 25 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 |