Skip to content

Instantly share code, notes, and snippets.

@jarmo
Created October 16, 2010 15:08
Show Gist options
  • Select an option

  • Save jarmo/629884 to your computer and use it in GitHub Desktop.

Select an option

Save jarmo/629884 to your computer and use it in GitHub Desktop.
class PhoneNumber
def initialize number
number.gsub!(/[\s-]*/, "")
@number = number
end
def valid?
@number =~ /^((\+\d{3,4})?\d{7,8})?$/
end
def to_s
@number
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment