Class: PicoPhone::PhoneNumber
- Inherits:
-
Object
- Object
- PicoPhone::PhoneNumber
- Defined in:
- lib/pico_phone/phone_number.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#area_code ⇒ String
Geographic area code digits, or empty string if none.
-
#can_be_internationally_dialled? ⇒ Boolean
False for numbers that only work within their own country.
-
#country ⇒ String
ISO 3166-1 alpha-2 region code (e.g. "US").
-
#country_code ⇒ Integer
E.g.
-
#e164 ⇒ String
E.g.
- #extension ⇒ String?
-
#format_in_original_format ⇒ String
Format using the same style (international vs. national) as the original input.
-
#full_e164 ⇒ String
E.164 format with extension appended using the configured prefix.
-
#full_international ⇒ String
International format with extension appended using the configured prefix.
-
#full_national ⇒ String
National format with extension appended using the configured prefix.
-
#geographical? ⇒ Boolean
True for fixed-line numbers tied to a geographic area code.
- #has_extension? ⇒ Boolean
- #impossible? ⇒ Boolean
-
#initialize(string, region = nil) ⇒ PhoneNumber
constructor
A new instance of PhoneNumber.
-
#international ⇒ String
E.g.
- #invalid? ⇒ Boolean
- #invalid_for_country?(region) ⇒ Boolean
-
#local_number ⇒ String
Subscriber number after the area code.
-
#mobile_dialing_format(region) ⇒ String
Format the number for convenient dialing on a mobile device in the given region.
-
#national ⇒ String
E.g.
-
#original ⇒ String?
The raw input string as passed to the constructor.
-
#out_of_country_format(region) ⇒ String
Format the number as it would be dialed from outside its home country.
- #possible? ⇒ Boolean
-
#possible_countries ⇒ Array<String>
Regions that could own this number based on length (unambiguous codes) or pattern (shared calling codes like +1 or +7).
-
#possible_for_type?(type) ⇒ Boolean
True when the number's digit count is consistent with the given type in its region.
-
#possible_with_reason ⇒ Symbol
Why the number is or is not possible.
-
#raw_international ⇒ String
International number digits with calling code, no formatting punctuation.
-
#raw_national ⇒ String
National significant number as plain digits, no formatting punctuation.
-
#to_s ⇒ String
E.164 for a valid number; falls back to #original for an invalid one.
-
#type ⇒ Symbol
:fixed_line, :mobile, :fixed_line_or_mobile, :toll_free, :premium_rate, :shared_cost, :voip, :personal_number, :pager, :uan, :voicemail, or :unknown.
- #valid? ⇒ Boolean
-
#valid_countries ⇒ Array<String>
Regions for which this number passes strict pattern validation.
- #valid_for_country?(region) ⇒ Boolean
Constructor Details
#initialize(string, region = nil) ⇒ PhoneNumber
Returns a new instance of PhoneNumber.
85 |
# File 'lib/pico_phone/phone_number.rb', line 85 def initialize(string, region = nil); end |
Class Method Details
.alpha_number?(string) ⇒ Boolean
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 |
# File 'lib/pico_phone/phone_number.rb', line 82 class PhoneNumber # @param string [String, nil] raw phone number input # @param region [String, nil] ISO 3166-1 alpha-2 region hint (e.g. "US") def initialize(string, region = nil); end # @return [Boolean] def valid?; end # @return [Boolean] def invalid?; end # @return [Boolean] def possible?; end # @return [Boolean] def impossible?; end # Why the number is or is not possible. # @return [Symbol] :is_possible, :is_possible_local_only, :too_short, :too_long, # :invalid_country_code, or :invalid_length def possible_with_reason; end # @return [String] e.g. "(510) 274-5656" def national; end # @return [String] e.g. "+1 510-274-5656" def international; end # @return [String] e.g. "+15102745656" def e164; end # @return [String, nil] def extension; end # @return [Boolean] def has_extension?; end # National format with extension appended using the configured prefix. # @return [String] def full_national; end # International format with extension appended using the configured prefix. # @return [String] def full_international; end # E.164 format with extension appended using the configured prefix. # @return [String] def full_e164; end # @return [Integer] e.g. 1 for US/CA, 61 for AU def country_code; end # @return [String] ISO 3166-1 alpha-2 region code (e.g. "US") def country; end # @return [String] geographic area code digits, or empty string if none def area_code; end # National significant number as plain digits, no formatting punctuation. # @return [String] def raw_national; end # International number digits with calling code, no formatting punctuation. # @return [String] def raw_international; end # @return [Symbol] :fixed_line, :mobile, :fixed_line_or_mobile, :toll_free, # :premium_rate, :shared_cost, :voip, :personal_number, :pager, :uan, # :voicemail, or :unknown def type; end # Subscriber number after the area code. Returns the full national number when # there is no geographic area code (e.g. mobile numbers in AU). # @return [String] def local_number; end # @param region [String] ISO 3166-1 alpha-2 region code # @return [Boolean] def valid_for_country?(region); end # @param region [String] ISO 3166-1 alpha-2 region code # @return [Boolean] def invalid_for_country?(region); end # The raw input string as passed to the constructor. Survives a failed parse. # @return [String, nil] def original; end # E.164 for a valid number; falls back to {#original} for an invalid one. # Returns an empty string when nil was passed as input. # @return [String] def to_s; end # Format using the same style (international vs. national) as the original input. # @return [String] def format_in_original_format; end # Format the number as it would be dialed from outside its home country. # @param region [String] ISO 3166-1 alpha-2 region of the caller # @return [String] def out_of_country_format(region); end # Format the number for convenient dialing on a mobile device in the given region. # @param region [String] ISO 3166-1 alpha-2 region of the caller # @return [String] def mobile_dialing_format(region); end # Regions that could own this number based on length (unambiguous codes) or # pattern (shared calling codes like +1 or +7). # @return [Array<String>] ISO 3166-1 alpha-2 region codes def possible_countries; end # Regions for which this number passes strict pattern validation. # @return [Array<String>] ISO 3166-1 alpha-2 region codes def valid_countries; end # True for fixed-line numbers tied to a geographic area code. # @return [Boolean] def geographical?; end # True when the number's digit count is consistent with the given type in its region. # More permissive than {#type}: a 10-digit US number is possible for both # :fixed_line_or_mobile and :toll_free since they share the same digit count. # @param type [Symbol] e.g. :mobile, :toll_free, :fixed_line # @return [Boolean] def possible_for_type?(type); end # False for numbers that only work within their own country. # @return [Boolean] def can_be_internationally_dialled?; end end |
Instance Method Details
#area_code ⇒ String
Returns geographic area code digits, or empty string if none.
138 |
# File 'lib/pico_phone/phone_number.rb', line 138 def area_code; end |
#can_be_internationally_dialled? ⇒ Boolean
False for numbers that only work within their own country.
211 |
# File 'lib/pico_phone/phone_number.rb', line 211 def can_be_internationally_dialled?; end |
#country ⇒ String
Returns ISO 3166-1 alpha-2 region code (e.g. "US").
135 |
# File 'lib/pico_phone/phone_number.rb', line 135 def country; end |
#country_code ⇒ Integer
Returns e.g. 1 for US/CA, 61 for AU.
132 |
# File 'lib/pico_phone/phone_number.rb', line 132 def country_code; end |
#e164 ⇒ String
Returns e.g. "+15102745656".
111 |
# File 'lib/pico_phone/phone_number.rb', line 111 def e164; end |
#extension ⇒ String?
114 |
# File 'lib/pico_phone/phone_number.rb', line 114 def extension; end |
#format_in_original_format ⇒ String
Format using the same style (international vs. national) as the original input.
177 |
# File 'lib/pico_phone/phone_number.rb', line 177 def format_in_original_format; end |
#full_e164 ⇒ String
E.164 format with extension appended using the configured prefix.
129 |
# File 'lib/pico_phone/phone_number.rb', line 129 def full_e164; end |
#full_international ⇒ String
International format with extension appended using the configured prefix.
125 |
# File 'lib/pico_phone/phone_number.rb', line 125 def full_international; end |
#full_national ⇒ String
National format with extension appended using the configured prefix.
121 |
# File 'lib/pico_phone/phone_number.rb', line 121 def full_national; end |
#geographical? ⇒ Boolean
True for fixed-line numbers tied to a geographic area code.
200 |
# File 'lib/pico_phone/phone_number.rb', line 200 def geographical?; end |
#has_extension? ⇒ Boolean
117 |
# File 'lib/pico_phone/phone_number.rb', line 117 def has_extension?; end |
#impossible? ⇒ Boolean
97 |
# File 'lib/pico_phone/phone_number.rb', line 97 def impossible?; end |
#international ⇒ String
Returns e.g. "+1 510-274-5656".
108 |
# File 'lib/pico_phone/phone_number.rb', line 108 def international; end |
#invalid? ⇒ Boolean
91 |
# File 'lib/pico_phone/phone_number.rb', line 91 def invalid?; end |
#invalid_for_country?(region) ⇒ Boolean
164 |
# File 'lib/pico_phone/phone_number.rb', line 164 def invalid_for_country?(region); end |
#local_number ⇒ String
Subscriber number after the area code. Returns the full national number when there is no geographic area code (e.g. mobile numbers in AU).
156 |
# File 'lib/pico_phone/phone_number.rb', line 156 def local_number; end |
#mobile_dialing_format(region) ⇒ String
Format the number for convenient dialing on a mobile device in the given region.
187 |
# File 'lib/pico_phone/phone_number.rb', line 187 def mobile_dialing_format(region); end |
#national ⇒ String
Returns e.g. "(510) 274-5656".
105 |
# File 'lib/pico_phone/phone_number.rb', line 105 def national; end |
#original ⇒ String?
The raw input string as passed to the constructor. Survives a failed parse.
168 |
# File 'lib/pico_phone/phone_number.rb', line 168 def original; end |
#out_of_country_format(region) ⇒ String
Format the number as it would be dialed from outside its home country.
182 |
# File 'lib/pico_phone/phone_number.rb', line 182 def out_of_country_format(region); end |
#possible? ⇒ Boolean
94 |
# File 'lib/pico_phone/phone_number.rb', line 94 def possible?; end |
#possible_countries ⇒ Array<String>
Regions that could own this number based on length (unambiguous codes) or pattern (shared calling codes like +1 or +7).
192 |
# File 'lib/pico_phone/phone_number.rb', line 192 def possible_countries; end |
#possible_for_type?(type) ⇒ Boolean
True when the number's digit count is consistent with the given type in its region. More permissive than #type: a 10-digit US number is possible for both :fixed_line_or_mobile and :toll_free since they share the same digit count.
207 |
# File 'lib/pico_phone/phone_number.rb', line 207 def possible_for_type?(type); end |
#possible_with_reason ⇒ Symbol
Why the number is or is not possible.
102 |
# File 'lib/pico_phone/phone_number.rb', line 102 def possible_with_reason; end |
#raw_international ⇒ String
International number digits with calling code, no formatting punctuation.
146 |
# File 'lib/pico_phone/phone_number.rb', line 146 def raw_international; end |
#raw_national ⇒ String
National significant number as plain digits, no formatting punctuation.
142 |
# File 'lib/pico_phone/phone_number.rb', line 142 def raw_national; end |
#to_s ⇒ String
E.164 for a valid number; falls back to #original for an invalid one. Returns an empty string when nil was passed as input.
173 |
# File 'lib/pico_phone/phone_number.rb', line 173 def to_s; end |
#type ⇒ Symbol
Returns :fixed_line, :mobile, :fixed_line_or_mobile, :toll_free, :premium_rate, :shared_cost, :voip, :personal_number, :pager, :uan, :voicemail, or :unknown.
151 |
# File 'lib/pico_phone/phone_number.rb', line 151 def type; end |
#valid? ⇒ Boolean
88 |
# File 'lib/pico_phone/phone_number.rb', line 88 def valid?; end |
#valid_countries ⇒ Array<String>
Regions for which this number passes strict pattern validation.
196 |
# File 'lib/pico_phone/phone_number.rb', line 196 def valid_countries; end |
#valid_for_country?(region) ⇒ Boolean
160 |
# File 'lib/pico_phone/phone_number.rb', line 160 def valid_for_country?(region); end |