Class: PicoPhone::PhoneNumber

Inherits:
Object
  • Object
show all
Defined in:
lib/pico_phone/phone_number.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(string, region = nil) ⇒ PhoneNumber

Returns a new instance of PhoneNumber.

Parameters:

  • string (String, nil)

    raw phone number input

  • region (String, nil) (defaults to: nil)

    ISO 3166-1 alpha-2 region hint (e.g. "US")



85
# File 'lib/pico_phone/phone_number.rb', line 85

def initialize(string, region = nil); end

Class Method Details

.alpha_number?(string) ⇒ Boolean

Parameters:

  • string (String)

Returns:

  • (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_codeString

Returns geographic area code digits, or empty string if none.

Returns:

  • (String)

    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.

Returns:

  • (Boolean)


211
# File 'lib/pico_phone/phone_number.rb', line 211

def can_be_internationally_dialled?; end

#countryString

Returns ISO 3166-1 alpha-2 region code (e.g. "US").

Returns:

  • (String)

    ISO 3166-1 alpha-2 region code (e.g. "US")



135
# File 'lib/pico_phone/phone_number.rb', line 135

def country; end

#country_codeInteger

Returns e.g. 1 for US/CA, 61 for AU.

Returns:

  • (Integer)

    e.g. 1 for US/CA, 61 for AU



132
# File 'lib/pico_phone/phone_number.rb', line 132

def country_code; end

#e164String

Returns e.g. "+15102745656".

Returns:

  • (String)

    e.g. "+15102745656"



111
# File 'lib/pico_phone/phone_number.rb', line 111

def e164; end

#extensionString?

Returns:

  • (String, nil)


114
# File 'lib/pico_phone/phone_number.rb', line 114

def extension; end

#format_in_original_formatString

Format using the same style (international vs. national) as the original input.

Returns:

  • (String)


177
# File 'lib/pico_phone/phone_number.rb', line 177

def format_in_original_format; end

#full_e164String

E.164 format with extension appended using the configured prefix.

Returns:

  • (String)


129
# File 'lib/pico_phone/phone_number.rb', line 129

def full_e164; end

#full_internationalString

International format with extension appended using the configured prefix.

Returns:

  • (String)


125
# File 'lib/pico_phone/phone_number.rb', line 125

def full_international; end

#full_nationalString

National format with extension appended using the configured prefix.

Returns:

  • (String)


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.

Returns:

  • (Boolean)


200
# File 'lib/pico_phone/phone_number.rb', line 200

def geographical?; end

#has_extension?Boolean

Returns:

  • (Boolean)


117
# File 'lib/pico_phone/phone_number.rb', line 117

def has_extension?; end

#impossible?Boolean

Returns:

  • (Boolean)


97
# File 'lib/pico_phone/phone_number.rb', line 97

def impossible?; end

#internationalString

Returns e.g. "+1 510-274-5656".

Returns:

  • (String)

    e.g. "+1 510-274-5656"



108
# File 'lib/pico_phone/phone_number.rb', line 108

def international; end

#invalid?Boolean

Returns:

  • (Boolean)


91
# File 'lib/pico_phone/phone_number.rb', line 91

def invalid?; end

#invalid_for_country?(region) ⇒ Boolean

Parameters:

  • region (String)

    ISO 3166-1 alpha-2 region code

Returns:

  • (Boolean)


164
# File 'lib/pico_phone/phone_number.rb', line 164

def invalid_for_country?(region); end

#local_numberString

Subscriber number after the area code. Returns the full national number when there is no geographic area code (e.g. mobile numbers in AU).

Returns:

  • (String)


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.

Parameters:

  • region (String)

    ISO 3166-1 alpha-2 region of the caller

Returns:

  • (String)


187
# File 'lib/pico_phone/phone_number.rb', line 187

def mobile_dialing_format(region); end

#nationalString

Returns e.g. "(510) 274-5656".

Returns:

  • (String)

    e.g. "(510) 274-5656"



105
# File 'lib/pico_phone/phone_number.rb', line 105

def national; end

#originalString?

The raw input string as passed to the constructor. Survives a failed parse.

Returns:

  • (String, nil)


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.

Parameters:

  • region (String)

    ISO 3166-1 alpha-2 region of the caller

Returns:

  • (String)


182
# File 'lib/pico_phone/phone_number.rb', line 182

def out_of_country_format(region); end

#possible?Boolean

Returns:

  • (Boolean)


94
# File 'lib/pico_phone/phone_number.rb', line 94

def possible?; end

#possible_countriesArray<String>

Regions that could own this number based on length (unambiguous codes) or pattern (shared calling codes like +1 or +7).

Returns:

  • (Array<String>)

    ISO 3166-1 alpha-2 region codes



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.

Parameters:

  • type (Symbol)

    e.g. :mobile, :toll_free, :fixed_line

Returns:

  • (Boolean)


207
# File 'lib/pico_phone/phone_number.rb', line 207

def possible_for_type?(type); end

#possible_with_reasonSymbol

Why the number is or is not possible.

Returns:

  • (Symbol)

    :is_possible, :is_possible_local_only, :too_short, :too_long, :invalid_country_code, or :invalid_length



102
# File 'lib/pico_phone/phone_number.rb', line 102

def possible_with_reason; end

#raw_internationalString

International number digits with calling code, no formatting punctuation.

Returns:

  • (String)


146
# File 'lib/pico_phone/phone_number.rb', line 146

def raw_international; end

#raw_nationalString

National significant number as plain digits, no formatting punctuation.

Returns:

  • (String)


142
# File 'lib/pico_phone/phone_number.rb', line 142

def raw_national; end

#to_sString

E.164 for a valid number; falls back to #original for an invalid one. Returns an empty string when nil was passed as input.

Returns:

  • (String)


173
# File 'lib/pico_phone/phone_number.rb', line 173

def to_s; end

#typeSymbol

Returns :fixed_line, :mobile, :fixed_line_or_mobile, :toll_free, :premium_rate, :shared_cost, :voip, :personal_number, :pager, :uan, :voicemail, or :unknown.

Returns:

  • (Symbol)

    :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

Returns:

  • (Boolean)


88
# File 'lib/pico_phone/phone_number.rb', line 88

def valid?; end

#valid_countriesArray<String>

Regions for which this number passes strict pattern validation.

Returns:

  • (Array<String>)

    ISO 3166-1 alpha-2 region codes



196
# File 'lib/pico_phone/phone_number.rb', line 196

def valid_countries; end

#valid_for_country?(region) ⇒ Boolean

Parameters:

  • region (String)

    ISO 3166-1 alpha-2 region code

Returns:

  • (Boolean)


160
# File 'lib/pico_phone/phone_number.rb', line 160

def valid_for_country?(region); end