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


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

def self.instance_for
  @instance ||= new
end

Instance Method Details

#lengthObject

A valid length (at least 3).


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

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) (defaults to: {})

    Hints (ignored).

Returns:

  • (Boolean)

    Always true.


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

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.


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

def split national_number
  [nil, national_number]
end