Class: Phones::Parser

Inherits:
Object
  • Object
show all
Defined in:
lib/phones/parser.rb

Constant Summary collapse

IGNORABLE_CHARACTERS =
/[a-zA-Z]|\-|\s|\.|\(|\)|\;|\:|\*|\&|\%|\$|\#|\@|\!/.freeze

Class Method Summary collapse

Class Method Details

.numberObject



36
37
38
# File 'lib/phones/parser.rb', line 36

def self.number
	@number
end

.parse(options) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/phones/parser.rb', line 17

def self.parse(options)
	# Let's figure out what the phone number is
	if options.class == Hash
		@number = options[:phone] || options[:number]
	elsif options.class == String
		@number = options
	else
		raise ArgumentError, "Pass a hash of options including a \"number\" key, or just a phone number"
	end

	# Now, let's remove all the characters we can ignore
	strip!

	# "+19252008843" or "19252008843" or "9252008843" are all common
	@phone = try_without_delimiters!

	@phone
end

.verbose!Object



40
41
42
# File 'lib/phones/parser.rb', line 40

def self.verbose!
	@verbose = true
end