floere/phony

View on GitHub
lib/phony/countries/india.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

# Indian phone numbers.
#
# http://en.wikipedia.org/wiki/Telephone_numbers_in_India
# http://en.wikipedia.org/wiki/Mobile_telephone_numbering_in_India
#
# http://www.dot.gov.in/numbering_plan/numberplanindex.htm
# http://www.dot.gov.in/numbering_plan/nnp2003.pdf
# http://www.dot.gov.in/numbering_plan/2012/msc_codes_28092012.pdf
#
#


sdca_with_2_digits = %w{ 11 20 22 33 39 40 44 50 60 70 79 80 }

sdca_with_3_digits = %w{
120 121 122 124 129 130 131 132 135 141 144 145 151 154 160 161 164 171 172 175 177 180 181 183 184 186 191 194
210 212 217 230 231 233 239 240 241 249 250 251 254 257 260 261 265 268 270 272 278 281 285 286 288 291 294
326 341 342 343 353 354 360 361 364 369 370 373 374 376 381 385 389
413 416 421 423 424 427 431 435 451 452 461 462 469 470 471 474 475 476 477 478 479 480 481 483 484 485 487 490 491 494 495 496 497
512 515 532 535 542 548 551 562 565 572 581 595
612 621 631 641 651 657 661 663 671 674 680
712 721 724 731 733 734 744 751 755 761 747 788
816 820 821 824 831 832 836 861 863 866 870 877 878 883 884 891
140
240 249 254 260 270 272
300 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 318 320 327 328 329 340 344 349 350 357 388
412 419 430 438 439 450 453 458 459 460 464 466 467 468
510 513 520 523 529 530 537 538 539 540 543 547 550 553 557 558 559 560 563 570 575 576 577 578 579 580 589 590 593 597 598 599
610 614 616 617 619 620 623 626 628 629 630 635 636 637 638 639 640 644 648 649 650 660 669 670 677 687 688 689
730 735 738 740 750 787 789
812 814 829 843 860 879 880 887 889 890 895 897 898 899
}



mobile = %w{ 91 92 93 94 97 98 99 }

pagers = %w{ 96 }

Phony.define do
  country '91',
    trunk('0') |
    one_of(sdca_with_3_digits) >> split(3, 2, 2) |
    one_of(sdca_with_2_digits) >> split(3, 2, 3) |
    one_of(mobile) >> split(3, 2, 3) |
    one_of(pagers) >> split(2, 3, 3) |
    fixed(4) >> split(3, 3) # fallback (4 digit sdca)
end