Class: FauxData::NationalIdGenerator

Inherits:
Object
  • Object
show all
Defined in:
lib/faux_data/national_id_generator.rb

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ NationalIdGenerator

Returns a new instance of NationalIdGenerator.



7
8
9
10
11
12
13
# File 'lib/faux_data/national_id_generator.rb', line 7

def initialize(opts = {})
    options = {
        :country_code => 'us'
    }.merge(opts)
    @country_code = options[:country_code]
    @@consumed_national_ids = Array.new
end

Instance Method Details

#national_idObject



16
17
18
19
20
21
22
23
24
# File 'lib/faux_data/national_id_generator.rb', line 16

def national_id
    id = ''
    while (not valid_national_id_us?(id)) 
        id = generate_national_id_us if @country_code == 'us'
        #pp id
    end
    @@consumed_national_ids << id
    return id
end

#national_idsObject



25
26
27
28
29
# File 'lib/faux_data/national_id_generator.rb', line 25

def national_ids
    ids = Array.new
    ids.replace @@consumed_national_ids
    return ids
end