Sha256: dfdfe03a299a34eccb1818ee0f80f7d1cc3e646dc6a2b16510281d5f3e8522b9

Contents?: true

Size: 679 Bytes

Versions: 12

Compression:

Stored size: 679 Bytes

Contents

# frozen_string_literal: true

module FFaker
  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

12 entries across 12 versions & 1 rubygems

Version Path
ffaker-2.23.0 lib/ffaker/nato_alphabet.rb
ffaker-2.22.0 lib/ffaker/nato_alphabet.rb
ffaker-2.21.0 lib/ffaker/nato_alphabet.rb
ffaker-2.20.0 lib/ffaker/nato_alphabet.rb
ffaker-2.19.0 lib/ffaker/nato_alphabet.rb
ffaker-2.18.0 lib/ffaker/nato_alphabet.rb
ffaker-2.17.0 lib/ffaker/nato_alphabet.rb
ffaker-2.16.0 lib/ffaker/nato_alphabet.rb
ffaker-2.15.0 lib/ffaker/nato_alphabet.rb
ffaker-2.14.0 lib/ffaker/nato_alphabet.rb
ffaker-2.13.0 lib/ffaker/nato_alphabet.rb
ffaker-2.12.0 lib/ffaker/nato_alphabet.rb