Class: Iz::PhoneNumber
- Inherits:
-
Object
- Object
- Iz::PhoneNumber
- Defined in:
- lib/iz/phone_number.rb
Constant Summary collapse
- REGEX =
/^(?:\+?(\d{1,3}))?[-. (]*(\d{3})[-. )]*(\d{3})[-. ]*(\d{4})(?: *x(\d+))?$/
Instance Attribute Summary collapse
-
#value ⇒ Object
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(phone_number) ⇒ PhoneNumber
constructor
A new instance of PhoneNumber.
- #valid? ⇒ Boolean
Constructor Details
#initialize(phone_number) ⇒ PhoneNumber
Returns a new instance of PhoneNumber.
7 8 9 |
# File 'lib/iz/phone_number.rb', line 7 def initialize(phone_number) self.value = phone_number end |
Instance Attribute Details
#value ⇒ Object
Returns the value of attribute value.
5 6 7 |
# File 'lib/iz/phone_number.rb', line 5 def value @value end |
Class Method Details
.is_phone_number?(value) ⇒ Boolean
15 16 17 18 |
# File 'lib/iz/phone_number.rb', line 15 def self.is_phone_number?(value) return false unless value value.to_s =~ REGEX end |
Instance Method Details
#valid? ⇒ Boolean
11 12 13 |
# File 'lib/iz/phone_number.rb', line 11 def valid? !!Iz::PhoneNumber.is_phone_number?(value) end |