Class: Phony::NationalSplitters::Default

Inherits:
DSL
  • Object
show all
Defined in:
lib/phony/national_splitters/default.rb

Overview

TODO: Default = Fixed.new(…)?

Direct Known Subclasses

None

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DSL

#>>, #country_for, #reserved

Class Method Details

.instance_forObject



8
9
10
# File 'lib/phony/national_splitters/default.rb', line 8

def self.instance_for
  @instance_for ||= new
end

Instance Method Details

#lengthObject

A valid length (at least 3).



42
43
44
# File 'lib/phony/national_splitters/default.rb', line 42

def length
  3
end

#plausible?(_rest, _size, _hints = {}) ⇒ Boolean

By default, the national part of a number is always plausible.

Examples:

Split the national part of a Swiss number.

Phony.plausible?("1234567") # => true

Parameters:

  • rest (String)

    An national part of a number (ignored).

  • size (Fixnum)

    Size (ignored).

  • hints (Hash)

    Hints (ignored).

Returns:

  • (Boolean)

    Always true.



36
37
38
# File 'lib/phony/national_splitters/default.rb', line 36

def plausible?(_rest, _size, _hints = {})
  true
end

#split(national_number) ⇒ Array<String>

“Splits” the national part of a phone number into a single piece.

Examples:

Split the national part of a Swiss number.

Phony.split("1234567") # => ["1234567"]

Parameters:

  • national_number (String)

    An national part of a number.

Returns:

  • (Array<String>)

    An Array with the given number part as its element.



21
22
23
# File 'lib/phony/national_splitters/default.rb', line 21

def split(national_number)
  [nil, national_number]
end