Class: Ubi::Memoria::Phone

Inherits:
Base
  • Object
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

Constructor Details

This class inherits a constructor from Ubi::Memoria::Base

Instance Attribute Details

#numberObject (readonly)

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



21
22
23
24
25
26
27
# File 'lib/ubi/memorias/phone.rb', line 21

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

#formatObject



11
12
13
# File 'lib/ubi/memorias/phone.rb', line 11

def format
  number && number.national
end

#parserObject



7
8
9
# File 'lib/ubi/memorias/phone.rb', line 7

def parser
  @number = Phonelib.parse(text.gsub(/\D/, ''), hint)
end

#rfcObject



15
16
17
# File 'lib/ubi/memorias/phone.rb', line 15

def rfc
  number && number.international
end