Parent

Validator::Email

Constants

LOCAL_LENGTH

Attributes

domain[RW]
local[RW]

Returns the local part (the left hand side of the @ sign in the email address) of the address

a = Email.new('vitaliy@gmail.com')
a.local #=> 'vitaliy'

Public Class Methods

new(value) click to toggle source
# File lib/validator/email.rb, line 12
def initialize(value)
  @value = value
  self.parse
end

Public Instance Methods

is_email?() click to toggle source
# File lib/validator/email.rb, line 21
def is_email?
  @value.split(/@/).size == 2
end
parse() click to toggle source
# File lib/validator/email.rb, line 17
def parse
  @local, @domain = @value.split(/@/)
end
valid?() click to toggle source

valid if passes all conditions

# File lib/validator/email.rb, line 34
def valid?
  is_email? and valid_by_local_length? and valid_by_regexp?
end
valid_by_local_length?(local_length = nil) click to toggle source
# File lib/validator/email.rb, line 25
def valid_by_local_length?(local_length = nil)
  @local.length <= (local_length || LOCAL_LENGTH)
end
valid_by_regexp?() click to toggle source
# File lib/validator/email.rb, line 29
def valid_by_regexp?
  @value =~ /^([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})$/
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.