Sha256: 0c96603857cac2e03eda1df9bb5f322666db3b70b5cee5d213e0c007e1726e27
Contents?: true
Size: 778 Bytes
Versions: 1
Compression:
Stored size: 778 Bytes
Contents
module OSU # Validates an osu email. Can also strip a name.# from an osu email. class Email VALID_EMAIL = /\A(?<name_n>[a-z]([a-z-]*[a-z])?\.[1-9]\d*)@([a-z]+\.|)osu.edu\z/i def self.valid?(email) case email when VALID_EMAIL then true else false end end attr_reader :email def initialize(email) raise InvalidEmailError, email unless self.class.valid?(email) @email = email.downcase end def name_n VALID_EMAIL.match(email)["name_n"] end # Raised when a string is an invalid email class InvalidEmailError < ArgumentError def initialize(email) super( "#{email} is not a valid OSU email. It must resemble name.\#@osu.edu" ) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
osu_person-0.3 | lib/osu/email.rb |