Class: KDL::Types::IDNEmail
- Inherits:
-
Email
- Object
- Value
- Value::Custom
- KDL::Types::IDNEmail
- Defined in:
- lib/kdl/types/email.rb
Constant Summary
Constants inherited from Value
Instance Attribute Summary collapse
-
#unicode_domain ⇒ Object
readonly
Returns the value of attribute unicode_domain.
Attributes inherited from Email
Attributes inherited from Value::Custom
Attributes inherited from Value
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(value, unicode_domain:, **kwargs) ⇒ IDNEmail
constructor
A new instance of IDNEmail.
- #unicode_value ⇒ Object
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_domain:, **kwargs) ⇒ IDNEmail
Returns a new instance of IDNEmail.
30 31 32 33 |
# File 'lib/kdl/types/email.rb', line 30 def initialize(value, unicode_domain:, **kwargs) super(value, **kwargs) @unicode_domain = unicode_domain end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class KDL::Value
Instance Attribute Details
#unicode_domain ⇒ Object (readonly)
Returns the value of attribute unicode_domain.
28 29 30 |
# File 'lib/kdl/types/email.rb', line 28 def unicode_domain @unicode_domain end |
Class Method Details
.call(value, type = 'email') ⇒ Object
35 36 37 38 39 40 41 |
# File 'lib/kdl/types/email.rb', line 35 def self.call(value, type = 'email') return nil unless value.is_a? ::KDL::Value::String local, domain, unicode_domain = Email::Parser.new(value.value, idn: true).parse new("#{local}@#{domain}", type: type, local: local, domain: domain, unicode_domain: unicode_domain) end |
Instance Method Details
#unicode_value ⇒ Object
43 44 45 |
# File 'lib/kdl/types/email.rb', line 43 def unicode_value "#{local}@#{unicode_domain}" end |