mini_phone 1.0.5 → 1.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/mini_phone/mini_phone.cc +47 -15
- data/lib/mini_phone/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4f7c87533de0643b9af5d9394d62a238208c34fa34e16effbb9064e9fd3578d7
|
4
|
+
data.tar.gz: 5868d8b76184925da0ba875fa0a5df7c3bb61f920b51f5d9391fd2d742335ddc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6bdb02eee2405855e49defd3e27d9eccd8934ec1bc1c02977b69d17026d32500969b443b053b1eece4ca7f72294a2d57349c19cfe14f6993c02dab6d21ec9d21
|
7
|
+
data.tar.gz: e57f59c8c2b75a1e4983d8a7fc3941fa1c641bd1c55eb13185bc9c8b35347b39a3ce301e65e021887f5bfc403ee8b0b5e5bad60d20e3604900418c0b6d46511e
|
@@ -125,6 +125,8 @@ static inline VALUE rb_phone_number_nullify_ivars(VALUE self) {
|
|
125
125
|
rb_iv_set(self, "@raw_national", Qnil);
|
126
126
|
rb_iv_set(self, "@dasherized_national", Qnil);
|
127
127
|
rb_iv_set(self, "@international", Qnil);
|
128
|
+
rb_iv_set(self, "@raw_international", Qnil);
|
129
|
+
rb_iv_set(self, "@dasherized_international", Qnil);
|
128
130
|
rb_iv_set(self, "@e164", Qnil);
|
129
131
|
rb_iv_set(self, "@country_code", Qnil);
|
130
132
|
rb_iv_set(self, "@region_code", Qnil);
|
@@ -252,6 +254,47 @@ extern "C" VALUE rb_phone_number_dasherized_national(VALUE self) {
|
|
252
254
|
return rb_iv_set(self, "@dasherized_national", result);
|
253
255
|
}
|
254
256
|
|
257
|
+
extern "C" VALUE rb_phone_number_country_code(VALUE self) {
|
258
|
+
if (rb_ivar_defined(self, rb_intern("@country_code"))) {
|
259
|
+
return rb_iv_get(self, "@country_code");
|
260
|
+
}
|
261
|
+
|
262
|
+
PhoneNumberInfo *phone_number_info;
|
263
|
+
Data_Get_Struct(self, PhoneNumberInfo, phone_number_info);
|
264
|
+
|
265
|
+
int code = phone_number_info->phone_number.country_code();
|
266
|
+
|
267
|
+
VALUE result = INT2NUM(code);
|
268
|
+
|
269
|
+
return rb_iv_set(self, "@country_code", result);
|
270
|
+
}
|
271
|
+
|
272
|
+
extern "C" VALUE rb_phone_number_dasherized_international(VALUE self) {
|
273
|
+
if (rb_ivar_defined(self, rb_intern("@dasherized_international"))) {
|
274
|
+
return rb_iv_get(self, "@dasherized_international");
|
275
|
+
}
|
276
|
+
|
277
|
+
VALUE national = rb_phone_number_dasherized_national(self);
|
278
|
+
VALUE cc = rb_fix2str(rb_phone_number_country_code(self), 10);
|
279
|
+
VALUE dash = rb_str_new("-", 1);
|
280
|
+
VALUE prefix = rb_str_concat(cc, dash);
|
281
|
+
VALUE result = rb_str_concat(prefix, national);
|
282
|
+
|
283
|
+
return rb_iv_set(self, "@dasherized_international", result);
|
284
|
+
}
|
285
|
+
|
286
|
+
extern "C" VALUE rb_phone_number_raw_international(VALUE self) {
|
287
|
+
if (rb_ivar_defined(self, rb_intern("@raw_international"))) {
|
288
|
+
return rb_iv_get(self, "@raw_international");
|
289
|
+
}
|
290
|
+
|
291
|
+
VALUE national = rb_phone_number_raw_national(self);
|
292
|
+
VALUE cc = rb_fix2str(rb_phone_number_country_code(self), 10);
|
293
|
+
VALUE result = rb_str_concat(cc, national);
|
294
|
+
|
295
|
+
return rb_iv_set(self, "@raw_international", result);
|
296
|
+
}
|
297
|
+
|
255
298
|
extern "C" VALUE rb_phone_number_valid_eh(VALUE self) {
|
256
299
|
if (rb_ivar_defined(self, rb_intern("@valid"))) {
|
257
300
|
return rb_iv_get(self, "@valid");
|
@@ -313,21 +356,6 @@ extern "C" VALUE rb_phone_number_region_code(VALUE self) {
|
|
313
356
|
return rb_iv_set(self, "@region_code", result);
|
314
357
|
}
|
315
358
|
|
316
|
-
extern "C" VALUE rb_phone_number_country_code(VALUE self) {
|
317
|
-
if (rb_ivar_defined(self, rb_intern("@country_code"))) {
|
318
|
-
return rb_iv_get(self, "@country_code");
|
319
|
-
}
|
320
|
-
|
321
|
-
PhoneNumberInfo *phone_number_info;
|
322
|
-
Data_Get_Struct(self, PhoneNumberInfo, phone_number_info);
|
323
|
-
|
324
|
-
int code = phone_number_info->phone_number.country_code();
|
325
|
-
|
326
|
-
VALUE result = INT2NUM(code);
|
327
|
-
|
328
|
-
return rb_iv_set(self, "@country_code", result);
|
329
|
-
}
|
330
|
-
|
331
359
|
extern "C" VALUE rb_phone_number_eql_eh(VALUE self, VALUE other) {
|
332
360
|
if (!rb_obj_is_instance_of(other, rb_cPhoneNumber)) {
|
333
361
|
return Qfalse;
|
@@ -481,6 +509,10 @@ extern "C" void Init_mini_phone(void) {
|
|
481
509
|
rb_define_method(rb_cPhoneNumber, "national", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_national), 0);
|
482
510
|
|
483
511
|
rb_define_method(rb_cPhoneNumber, "raw_national", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_raw_national), 0);
|
512
|
+
rb_define_method(rb_cPhoneNumber, "raw_international",
|
513
|
+
reinterpret_cast<VALUE (*)(...)>(rb_phone_number_raw_international), 0);
|
514
|
+
rb_define_method(rb_cPhoneNumber, "dasherized_international",
|
515
|
+
reinterpret_cast<VALUE (*)(...)>(rb_phone_number_dasherized_international), 0);
|
484
516
|
rb_define_method(rb_cPhoneNumber, "dasherized_national",
|
485
517
|
reinterpret_cast<VALUE (*)(...)>(rb_phone_number_dasherized_national), 0);
|
486
518
|
rb_define_method(rb_cPhoneNumber, "international", reinterpret_cast<VALUE (*)(...)>(rb_phone_number_international),
|
data/lib/mini_phone/version.rb
CHANGED