class Phony::NationalSplitters::Regex
National splitter class to split the ndc-local part of a number.
Countries can create new instances according to their needs.
Note: Countries should use instance_for
to avoid getting new local splitter instances.
Attributes
Public Class Methods
Source
# File lib/phony/national_splitters/regex.rb, line 19 def self.instance_for(regex, on_fail_take = nil, options = {}) new regex, on_fail_take, options end
Get a splitter for the given format.
Note: Not cached.
Source
# File lib/phony/national_splitters/regex.rb, line 23 def initialize(regex, on_fail_take = nil, options = {}) super(on_fail_take, options) @regex = regex end
Calls superclass method
Phony::NationalSplitters::Fixed::new
Public Instance Methods
Source
# File lib/phony/national_splitters/regex.rb, line 46 def length # raise "#{self.class.name} has no length that can be automatically extracted." end
A valid length.
Source
# File lib/phony/national_splitters/regex.rb, line 34 def split(national_number) # Improve matching. # return [@zero, national_number.slice!(0..::Regexp.last_match(1).size - 1), national_number] if national_number =~ regex # Not found. # super(national_number) end
Split a local number according to an assumed country specific format.
Examples
-
split ‘3643533’ # => [‘364’, ‘35’, ‘33’] # (Switzerland)
Calls superclass method
Phony::NationalSplitters::Fixed#split