class RubyEmail::Core

Abstract class to inherit and complete by adding the REGEXP constant

Public Class Methods

match(str) click to toggle source

Check if the string is a valid email and details how @param str [::String] string to match @raise [ArgumentError] if str is not a String @return [MatchData or NilClass] matched email with the keys “local” and “domain”

# File lib/ruby_email/core.rb, line 17
def self.match str
  raise ArgumentError, "Cannot validate a `#{str.class}`. Only `String` can be." unless str.is_a?(String)
  str.match regexp
end
regexp() click to toggle source

@return [Regexp] constant to erase in the children

# File lib/ruby_email/core.rb, line 23
def self.regexp
  self::REGEXP
  #raise NoMethodError, "Not implemented in #{self.class}"
end
validates?(str) click to toggle source

Check if the {::String} is a valid email. @param str [::String] string to match @raise [ArgumentError] if str is not a String @return [TrueClass or FalseClass]

# File lib/ruby_email/core.rb, line 9
def self.validates? str
  !!match(str)
end