class Phony::NationalSplitters::Fixed
TODO
Attributes
Public Class Methods
Source
# File lib/phony/national_splitters/fixed.rb, line 16 def self.instance_for *parameters @mapping[parameters] ||= new(*parameters) end
Get a splitter for the given format.
Caches the created splitter for the given format.
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
Source
# File lib/phony/national_splitters/fixed.rb, line 35 def length @size end
A valid length.
Source
# 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.slice(@size..)] end
Takes a national number and splits it into ndc and rest.