Class: Filemaker::Model::Types::Email
- Inherits:
-
Object
- Object
- Filemaker::Model::Types::Email
- Defined in:
- lib/filemaker/model/types/email.rb
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
-
#initialize(value) ⇒ Email
constructor
A new instance of Email.
-
#to_query ⇒ Object
In FileMaker, at-sign is for wildcard query.
- #to_s ⇒ Object
- #value ⇒ Object
- #value=(v) ⇒ Object
Constructor Details
#initialize(value) ⇒ Email
Returns a new instance of Email.
5 6 7 8 9 |
# File 'lib/filemaker/model/types/email.rb', line 5 def initialize(value) # to_s incoming value, this can prevent similar type from # nesting deeply @value = value.nil? ? nil : value.to_s end |
Instance Method Details
#==(other) ⇒ Object Also known as: eql?
27 28 29 |
# File 'lib/filemaker/model/types/email.rb', line 27 def ==(other) to_s == other.to_s end |
#to_query ⇒ Object
In FileMaker, at-sign is for wildcard query. In order to search for email, we need to escape at-sign. Note the single-quote escaping! e.g. ‘[email protected]’ will become ‘a\@host.com’
35 36 37 |
# File 'lib/filemaker/model/types/email.rb', line 35 def to_query value.gsub('@', '\@') end |
#to_s ⇒ Object
23 24 25 |
# File 'lib/filemaker/model/types/email.rb', line 23 def to_s value end |
#value ⇒ Object
11 12 13 14 15 16 17 |
# File 'lib/filemaker/model/types/email.rb', line 11 def value email = @value&.strip&.split(%r{,|\(|\/|\s}) &.reject(&:empty?)&.first&.downcase &.gsub(/[\uFF20\uFE6B\u0040]/, '@') email&.include?('@') ? email : nil end |
#value=(v) ⇒ Object
19 20 21 |
# File 'lib/filemaker/model/types/email.rb', line 19 def value=(v) self.value = v end |