Sha256: 1e0626f9584eb10c4b35f7ef60e8827098d69e84fc7370c3f26fde431c61b80c

Contents?: true

Size: 681 Bytes

Versions: 9

Compression:

Stored size: 681 Bytes

Contents

# frozen_string_literal: true

module FFakerTW
  module NatoAlphabet
    extend ModuleUtils
    extend self

    STOP_CODE = 'STOP'
    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

9 entries across 9 versions & 1 rubygems

Version Path
ffakerTW-1.8.0 lib/ffakerTW/nato_alphabet.rb
ffakerTW-1.7.0 lib/ffakerTW/nato_alphabet.rb
ffakerTW-1.6.0 lib/ffakerTW/nato_alphabet.rb
ffakerTW-1.5.0 lib/ffakerTW/nato_alphabet.rb
ffakerTW-1.4.0 lib/ffakerTW/nato_alphabet.rb
ffakerTW-1.3.0 lib/ffakerTW/nato_alphabet.rb
ffakerTW-1.2.0 lib/ffakerTW/nato_alphabet.rb
ffakerTW-1.1.0 lib/ffakerTW/nato_alphabet.rb
ffakerTW-0.1.0 lib/ffakerTW/nato_alphabet.rb