Class: Wagon::PhoneNumber
- Inherits:
-
Object
- Object
- Wagon::PhoneNumber
- Defined in:
- lib/wagon/phone_number.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
-
#initialize(type, value) ⇒ PhoneNumber
constructor
A new instance of PhoneNumber.
- #to_s ⇒ Object
Constructor Details
#initialize(type, value) ⇒ PhoneNumber
Returns a new instance of PhoneNumber.
10 11 12 |
# File 'lib/wagon/phone_number.rb', line 10 def initialize(type, value) @type, @value = type, value end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
3 4 5 |
# File 'lib/wagon/phone_number.rb', line 3 def type @type end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
3 4 5 |
# File 'lib/wagon/phone_number.rb', line 3 def value @value end |
Class Method Details
.extract_from_string(string) ⇒ Object
5 6 7 8 |
# File 'lib/wagon/phone_number.rb', line 5 def self.extract_from_string(string) string.strip =~ /([\)\(\+\s\-\d]+)(\((.*)\))?$/ self.new($3 || 'Home', $1.strip) end |
Instance Method Details
#==(other) ⇒ Object
14 15 16 17 |
# File 'lib/wagon/phone_number.rb', line 14 def ==(other) type == other.type && value == other.value end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/wagon/phone_number.rb', line 19 def to_s self.value end |