|
|
|
@ -1,4 +1,5 @@
|
|
|
|
|
class Contact
|
|
|
|
|
# add setters with validation
|
|
|
|
|
attr_reader :phone, :telegram, :email
|
|
|
|
|
|
|
|
|
|
def initialize(args = {})
|
|
|
|
@ -20,6 +21,7 @@ class Contact
|
|
|
|
|
@phone || @telegram || @email
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# getSingleContact
|
|
|
|
|
def info
|
|
|
|
|
return "Phone: #{@phone}" if @phone
|
|
|
|
|
return "Telegram: #{@telegram}" if @telegram
|
|
|
|
@ -34,6 +36,7 @@ class Contact
|
|
|
|
|
/\A\+?[0-9]{9,15}\z/.match?(phone)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
# self
|
|
|
|
|
def valid_telegram?(telegram)
|
|
|
|
|
/\A@[A-Za-z0-9_]{5,32}\z/.match?(telegram)
|
|
|
|
|
end
|
|
|
|
|