Module: FFaker::NatoAlphabet

Extended by:
ModuleUtils, NatoAlphabet
Included in:
NatoAlphabet
Defined in:
lib/ffaker/nato_alphabet.rb

Constant Summary collapse

ALPHABET_CODES =
%w(ALPHA BRAVO CHARLIE DELTA ECHO FOXTROT GOLF HOTEL INDIA JULIETT KILO LIMA MIKE NOVEMBER OSCAR PAPA QUEBEC ROMEO SIERRA TANGO UNIFORM VICTOR WHISKEY XRAY YANKEE ZULU)
NUMERIC_CODES =
%w(ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE ZERO)
STOP_CODE =
'STOP'
CODES =
ALPHABET_CODES + NUMERIC_CODES + [STOP_CODE]

Instance Method Summary collapse

Methods included from ModuleUtils

const_missing, k, underscore

Instance Method Details

#alphabetic_codeObject



17
18
19
# File 'lib/ffaker/nato_alphabet.rb', line 17

def alphabetic_code
  ALPHABET_CODES.sample
end

#callsignObject



25
26
27
# File 'lib/ffaker/nato_alphabet.rb', line 25

def callsign
  codify('?-?-#')
end

#codeObject



13
14
15
# File 'lib/ffaker/nato_alphabet.rb', line 13

def code
  CODES.sample
end

#codify(masks) ⇒ Object



29
30
31
32
33
34
35
36
37
38
# File 'lib/ffaker/nato_alphabet.rb', line 29

def codify(masks)
  masks.scan(/./).map do |c|
    case c
    when '#' then NUMERIC_CODES.sample
    when '?' then ALPHABET_CODES.sample
    when '.' then STOP_CODE
    else c
    end
  end.join
end

#numeric_codeObject



21
22
23
# File 'lib/ffaker/nato_alphabet.rb', line 21

def numeric_code
  NUMERIC_CODES.sample
end