Class: HoboFields::EmailAddress

Inherits:
String
  • Object
show all
Defined in:
lib/hobo_fields/email_address.rb

Constant Summary collapse

COLUMN_TYPE =
:string

Instance Method Summary collapse

Instance Method Details

#to_html(xmldoctype = true) ⇒ Object



15
16
17
# File 'lib/hobo_fields/email_address.rb', line 15

def to_html(xmldoctype = true)
  self.sub('@', " at ").gsub('.', ' dot ')
end

#valid?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/hobo_fields/email_address.rb', line 11

def valid?
  self =~ /^\s*([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\s*$/i
end

#validateObject



7
8
9
# File 'lib/hobo_fields/email_address.rb', line 7

def validate
  I18n.t("activerecord.errors.messages.invalid") unless valid? || blank?
end