Class: Wagon::PhoneNumber

Inherits:
Object
  • Object
show all
Defined in:
lib/wagon/phone_number.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

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

#typeObject (readonly)

Returns the value of attribute type.



3
4
5
# File 'lib/wagon/phone_number.rb', line 3

def type
  @type
end

#valueObject (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_sObject



19
20
21
# File 'lib/wagon/phone_number.rb', line 19

def to_s
  self.value
end