Class: KDL::Types::Email

Inherits:
Value
  • Object
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

#format, #type, #value

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Value

#as_type, from, #stringify_value, #to_s

Constructor Details

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

Returns a new instance of Email.



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

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

Instance Attribute Details

#domainObject (readonly)

Returns the value of attribute domain.



6
7
8
# File 'lib/kdl/types/email.rb', line 6

def domain
  @domain
end

#localObject (readonly)

Returns the value of attribute local.



6
7
8
# File 'lib/kdl/types/email.rb', line 6

def local
  @local
end

Class Method Details

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



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

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