Module: FFaker::NatoAlphabet
Constant Summary
collapse
- STOP_CODE =
'STOP'
- CODES =
ALPHABET_CODES + NUMERIC_CODES + [STOP_CODE]
Instance Method Summary
collapse
const_missing, k, luhn_check, underscore, unique
#fetch_sample, #rand, #shuffle
Instance Method Details
#alphabetic_code ⇒ Object
15
16
17
|
# File 'lib/ffaker/nato_alphabet.rb', line 15
def alphabetic_code
fetch_sample(ALPHABET_CODES)
end
|
#callsign ⇒ Object
23
24
25
|
# File 'lib/ffaker/nato_alphabet.rb', line 23
def callsign
codify('?-?-#')
end
|
#code ⇒ Object
11
12
13
|
# File 'lib/ffaker/nato_alphabet.rb', line 11
def code
fetch_sample(CODES)
end
|
#codify(masks) ⇒ Object
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/ffaker/nato_alphabet.rb', line 27
def codify(masks)
masks.scan(/./).map do |c|
case c
when '#' then fetch_sample(NUMERIC_CODES)
when '?' then fetch_sample(ALPHABET_CODES)
when '.' then STOP_CODE
else c
end
end.join
end
|
#numeric_code ⇒ Object
19
20
21
|
# File 'lib/ffaker/nato_alphabet.rb', line 19
def numeric_code
fetch_sample(NUMERIC_CODES)
end
|