Sha256: 1d1ab7d83b792530655eec4943bbc5280071b2274f862ff421fca7b79b2caa50

Contents?: true

Size: 531 Bytes

Versions: 3

Compression:

Stored size: 531 Bytes

Contents

# encoding: utf-8

module Faker
  module Locale
    extend ModuleUtils
    extend self

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

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

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
ffaker-1.30.0 lib/ffaker/locale.rb
ffaker-1.25.0 lib/ffaker/locale.rb
ffaker-1.24.0 lib/ffaker/locale.rb