Class: Ubi::Memoria::Email

Inherits:
Base
  • Object
show all
Defined in:
lib/ubi/memorias/email.rb

Overview

An Electronic Mail

Instance Attribute Summary

Attributes inherited from Base

#hint, #opts, #text

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#==, extract_text, #format, inherited, key, name, parse, parse!, #parser, plural, #to_s

Constructor Details

#initialize(text, _hint = nil, opts = {}) ⇒ Email

Clean up regex on init



8
9
10
11
12
13
# File 'lib/ubi/memorias/email.rb', line 8

def initialize(text, _hint = nil, opts = {})
  text = text.downcase.gsub(/^\(|\.$/, '')
  @text = text
  # @addr = text
  @opts = opts
end

Class Method Details

.regex(_hint) ⇒ Object

Email regex



23
24
25
26
27
28
29
30
# File 'lib/ubi/memorias/email.rb', line 23

def regex(_hint)
  %r{
    ([a-z0-9!#$%&'*+/=?^_`{|}~-]+
    (?:\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@
    (?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+
    (?:[a-z0-9-]*[a-z0-9])?)(?:\W|\s|$)
  }x
end