Sha256: 33f494276f40daf1a87766e963d780c1b473f3712a293388fa9295d24358a244

Contents?: true

Size: 517 Bytes

Versions: 12

Compression:

Stored size: 517 Bytes

Contents

# frozen_string_literal: true

module FFaker
  module Locale
    extend ModuleUtils
    extend self

    def code(given_language = nil)
      code_index = LANGUAGE.index(given_language)
      return LANGUAGE_CODE[code_index] if given_language && code_index

      fetch_sample(LANGUAGE_CODE)
    end

    def language(given_code = nil)
      language_index = LANGUAGE_CODE.index(given_code&.upcase)
      return LANGUAGE[language_index] if given_code && language_index

      fetch_sample(LANGUAGE)
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

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