Class: KDL::Types::IDNHostname::Validator
- Inherits:
-
Hostname::Validator
- Object
- Hostname::Validator
- KDL::Types::IDNHostname::Validator
- Defined in:
- lib/kdl/types/hostname/validator.rb
Constant Summary
Constants inherited from Hostname::Validator
Instance Attribute Summary collapse
-
#unicode ⇒ Object
readonly
Returns the value of attribute unicode.
Attributes inherited from Hostname::Validator
Instance Method Summary collapse
-
#initialize(string) ⇒ Validator
constructor
A new instance of Validator.
Methods inherited from Hostname::Validator
Constructor Details
#initialize(string) ⇒ Validator
Returns a new instance of Validator.
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/kdl/types/hostname/validator.rb', line 38 def initialize(string) is_ascii = string.split('.').any? { |x| x.start_with?('xn--') } if is_ascii super(string) @unicode = SimpleIDN.to_unicode(string) else super(SimpleIDN.to_ascii(string)) @unicode = string end end |
Instance Attribute Details
#unicode ⇒ Object (readonly)
Returns the value of attribute unicode.
36 37 38 |
# File 'lib/kdl/types/hostname/validator.rb', line 36 def unicode @unicode end |