class Phony::NationalSplitters::Fixed

TODO

Attributes

special_splitter[W]

Public Class Methods

instance_for(*parameters) click to toggle source

Get a splitter for the given format.

Caches the created splitter for the given format.

# File lib/phony/national_splitters/fixed.rb, line 16
def self.instance_for *parameters
  @mapping[parameters] ||= new(*parameters)
end
new(size, _options = {}) click to toggle source
# File lib/phony/national_splitters/fixed.rb, line 20
def initialize(size, _options = {})
  @size = size
  @zero = nil # options[:zero] == false ? nil : '0'
end

Public Instance Methods

length() click to toggle source

A valid length.

# File lib/phony/national_splitters/fixed.rb, line 35
def length
  @size
end
split(national_number) click to toggle source

Takes a national number and splits it into ndc and rest.

# File lib/phony/national_splitters/fixed.rb, line 27
def split(national_number)
  return [@zero, national_number] unless @size

  [@zero, national_number.slice!(0...@size), national_number]
end