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



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

#formatObject



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

def format
  number && number.e164
end

#internationalObject



19
20
21
# File 'lib/ubi/memorias/phone.rb', line 19

def international
  number && number.international
end

#nationalObject



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

def national
  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