Sha256: 05d712e171efbe275be0bd2c6777a0a0d8a30bdfec9b44e1f8052ce34465ea4d
Contents?: true
Size: 291 Bytes
Versions: 15
Compression:
Stored size: 291 Bytes
Contents
class PhoneNumber < String def initialize(value) super(value.to_s) end def valid? has_ten_digits? end def has_ten_digits? self =~ /\d{9}/ end def inspect self.to_s end def to_s "(#{self[0..2]}) #{self[3..5]}-#{self[6..9]}" if valid? end end
Version data entries
15 entries across 15 versions & 1 rubygems