class Ubi::Memoria::Email

An Electronic Mail

Public Class Methods

new(text, _hint = nil, opts = {}) click to toggle source

Clean up regex on init

# 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
regex(_hint) click to toggle source

Email regex

# 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