Sha256: d9a0c159784b431b327c9c1dbd1ad233b92e2113c4e2d7bb4dae486348fdac3e
Contents?: true
Size: 1.17 KB
Versions: 6
Compression:
Stored size: 1.17 KB
Contents
# frozen_string_literal: true require_relative '../../lib/LittleWeasel/modules/locale' module Support # This module contains methods to help with dictionary files. class Locale include LittleWeasel::Modules::Locale attr_accessor :language, :region def initialize(language:, region:) self.language = language self.region = region end end module FileHelpers module_function def locale_for(language:, region: nil) Locale.new(language: language, region: region).locale end def region_dictionary_path language:, region: file_name = locale_for language: language, region: region dictionary_path_for file_name: file_name end def language_dictionary_path language: file_name = locale_for language: language dictionary_path_for file_name: file_name end # :reek:UtilityFunction - ignored, this is only for specs. def dictionary_path_for(locale: nil, file_name: nil) file_name ||= locale File.join(File.dirname(__FILE__), "files/#{file_name}.txt") end def dictionary_words_for(dictionary_file_path:) File.read(dictionary_file_path, mode: 'r')&.split end end end
Version data entries
6 entries across 6 versions & 1 rubygems