Class: KDL::Types::Email

Inherits:
Value::Custom show all
Defined in:
lib/kdl/types/email.rb,
lib/kdl/types/email/parser.rb

Direct Known Subclasses

IDNEmail

Defined Under Namespace

Classes: Parser, Tokenizer

Constant Summary

Constants inherited from Value

Value::Null

Instance Attribute Summary collapse

Attributes inherited from Value::Custom

#oriinal_value

Attributes inherited from Value

#format, #type, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Value::Custom

#to_v1, #to_v2, #version

Methods inherited from Value

#==, #as_type, from, #inspect, #method_missing, #respond_to_missing?, #stringify_value, #to_s, #to_v2, #version

Constructor Details

#initialize(value, local:, domain:, **kwargs) ⇒ Email

Returns a new instance of Email.



10
11
12
13
14
# File 'lib/kdl/types/email.rb', line 10

def initialize(value, local:, domain:, **kwargs)
  super(value, **kwargs)
  @local = local
  @domain = domain
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class KDL::Value

Instance Attribute Details

#domainObject (readonly)

Returns the value of attribute domain.



8
9
10
# File 'lib/kdl/types/email.rb', line 8

def domain
  @domain
end

#localObject (readonly)

Returns the value of attribute local.



8
9
10
# File 'lib/kdl/types/email.rb', line 8

def local
  @local
end

Class Method Details

.call(value, type = 'email') ⇒ Object



16
17
18
19
20
21
22
# File 'lib/kdl/types/email.rb', line 16

def self.call(value, type = 'email')
  return nil unless value.is_a? ::KDL::Value::String

  local, domain = Parser.new(value.value).parse

  new(value.value, type: type, local: local, domain: domain)
end