Class: KDL::Types::IDNEmail
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
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
#as_type, from, #stringify_value, #to_s
Constructor Details
#initialize(value, unicode_domain:, **kwargs) ⇒ IDNEmail
Returns a new instance of IDNEmail.
28 29 30 31 |
# File 'lib/kdl/types/email.rb', line 28 def initialize(value, unicode_domain:, **kwargs) super(value, **kwargs) @unicode_domain = unicode_domain end |
Instance Attribute Details
#unicode_domain ⇒ Object (readonly)
Returns the value of attribute unicode_domain.
26 27 28 |
# File 'lib/kdl/types/email.rb', line 26 def unicode_domain @unicode_domain end |
Class Method Details
.call(value, type = 'email') ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/kdl/types/email.rb', line 33 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
41 42 43 |
# File 'lib/kdl/types/email.rb', line 41 def unicode_value "#{local}@#{unicode_domain}" end |