Class: Ubi::Memoria::Phone
- Inherits:
-
Base
- Object
- Base
- Ubi::Memoria::Phone
show all
- Defined in:
- lib/ubi/memorias/phone.rb
Overview
A Phone! mobile? landline? who is calling???
Instance Attribute Summary collapse
Attributes inherited from Base
#hint, #opts, #text
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#==, extract_text, inherited, #initialize, key, name, parse, parse!, plural, #to_s
Instance Attribute Details
#number ⇒ Object
Returns the value of attribute number.
5
6
7
|
# File 'lib/ubi/memorias/phone.rb', line 5
def number
@number
end
|
Class Method Details
.regex(_hint = nil) ⇒ Object
25
26
27
28
29
30
31
|
# File 'lib/ubi/memorias/phone.rb', line 25
def regex(_hint = nil)
/
(?:^|\s)((?:\+\(?\d{1,3}\W)?[\._\-\/\s]*
\(?\s*?\d{2,3}\s*?\)?[\._\-\/\s]*\d{3,5}
[\._\-\/\s]*\d{4,5})(?:\s|$)
/x
end
|
Instance Method Details
11
12
13
|
# File 'lib/ubi/memorias/phone.rb', line 11
def format
number && number.e164
end
|
#international ⇒ Object
19
20
21
|
# File 'lib/ubi/memorias/phone.rb', line 19
def international
number && number.international
end
|
#national ⇒ Object
15
16
17
|
# File 'lib/ubi/memorias/phone.rb', line 15
def national
number && number.national
end
|
#parser ⇒ Object
7
8
9
|
# File 'lib/ubi/memorias/phone.rb', line 7
def parser
@number = Phonelib.parse(text.gsub(/\D/, ''), hint)
end
|