Sha256: 58984fe7bef93cc5bb55d54c4f5315c0490a3dc87be9d8c7adb4c13c10cb1f36

Contents?: true

Size: 952 Bytes

Versions: 6

Compression:

Stored size: 952 Bytes

Contents

# encoding: utf-8

module FFaker
  module NatoAlphabet
    extend ModuleUtils
    extend self

    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].freeze
    NUMERIC_CODES = %w[ONE TWO THREE FOUR FIVE SIX SEVEN EIGHT NINE ZERO].freeze
    STOP_CODE = 'STOP'.freeze
    CODES = ALPHABET_CODES + NUMERIC_CODES + [STOP_CODE]

    def code
      fetch_sample(CODES)
    end

    def alphabetic_code
      fetch_sample(ALPHABET_CODES)
    end

    def numeric_code
      fetch_sample(NUMERIC_CODES)
    end

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

    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
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
ffaker-2.11.0 lib/ffaker/nato_alphabet.rb
ffaker-2.10.0 lib/ffaker/nato_alphabet.rb
ffaker-2.9.0 lib/ffaker/nato_alphabet.rb
ffaker-2.8.1 lib/ffaker/nato_alphabet.rb
ffaker-2.8.0 lib/ffaker/nato_alphabet.rb
ffaker-2.7.0 lib/ffaker/nato_alphabet.rb