Class: Faker::Code
Constant Summary
Constants inherited from Base
Base::Letters, Base::Numbers, Base::ULetters
Class Method Summary collapse
-
.ean(base = 13) ⇒ Object
By default generates 13 sign ean code in format 1234567890123 You can pass 8 to generate ean8 code.
-
.isbn(base = 10) ⇒ Object
By default generates 10 sign isbn code in format 123456789-X You can pass 13 to generate new 13 sign code.
-
.npi ⇒ Object
Generates a 10 digit NPI (National Provider Identifier issued to health care providers in the United States).
-
.nric(min_age = 18, max_age = 65) ⇒ Object
By default generates a Singaporean NRIC ID for someone who is born between the age of 18 and 65.
- .rut ⇒ Object
Methods inherited from Base
bothify, fetch, flexible, letterify, method_missing, numerify, parse, rand_in_range, regexify, translate
Class Method Details
.ean(base = 13) ⇒ Object
By default generates 13 sign ean code in format 1234567890123 You can pass 8 to generate ean8 code
19 20 21 |
# File 'lib/faker/code.rb', line 19 def ean(base = 13) base == 8 ? generate_base8_ean : generate_base13_ean end |
.isbn(base = 10) ⇒ Object
By default generates 10 sign isbn code in format 123456789-X You can pass 13 to generate new 13 sign code
13 14 15 |
# File 'lib/faker/code.rb', line 13 def isbn(base = 10) base == 13 ? generate_base13_isbn : generate_base10_isbn end |
.npi ⇒ Object
Generates a 10 digit NPI (National Provider Identifier issued to health care providers in the United States)
7 8 9 |
# File 'lib/faker/code.rb', line 7 def npi Random.new.rand(10 ** 10).to_s.rjust(10, '0') end |
.nric(min_age = 18, max_age = 65) ⇒ Object
By default generates a Singaporean NRIC ID for someone who is born between the age of 18 and 65.
31 32 33 34 35 36 37 38 |
# File 'lib/faker/code.rb', line 31 def nric(min_age = 18, max_age = 65) birthyear = Date.birthday(min_age, max_age).year prefix = birthyear < 2000 ? 'S' : 'T' values = birthyear.to_s[-2..-1] values << regexify(/\d{5}/) check_alpha = generate_nric_check_alphabet(values, prefix) "#{prefix}#{values}#{check_alpha}" end |