Sha256: e8a0bd43acb68600f499ddb0262d0657c8a6d3aaa45f75fb402e00e8597a291f
Contents?: true
Size: 899 Bytes
Versions: 7
Compression:
Stored size: 899 Bytes
Contents
module Torasup class PhoneNumber attr_reader :number, :country_code, :country_id, :area_code, :prefix, :local_number, :location, :operator def initialize(phone_number) parse_phone_number(phone_number) end private def parse_phone_number(number) @number = Phony.normalize(number) number_parts = split_number @country_code = number_parts.shift @country_id = Torasup.country_id(@country_code) area_code_or_prefix = number_parts.shift local_number = number_parts.join @location = Location.new(@country_id, area_code_or_prefix) @area_code = @location.area_code @operator = Operator.new(@country_code, area_code_or_prefix, local_number) @prefix = @operator.prefix @local_number = operator.local_number end def split_number Phony.split(@number).reject { |part| part == false } end end end
Version data entries
7 entries across 7 versions & 1 rubygems