From b4b556e34812a9653ba4b0a55e65aafa00524f52 Mon Sep 17 00:00:00 2001 From: Kouhei Sutou Date: Fri, 20 Sep 2013 22:04:19 +0900 Subject: [PATCH] Add private module to provide helper methods --- lib/locale/driver/env.rb | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/locale/driver/env.rb b/lib/locale/driver/env.rb index df54503..69232f5 100644 --- a/lib/locale/driver/env.rb +++ b/lib/locale/driver/env.rb @@ -66,12 +66,21 @@ def locales # * Returns: the system charset. def charset # :nodoc: [ENV["LC_ALL"], ENV["LC_CTYPE"], ENV["LANG"]].each do |env| - next if env.nil? - next if env.empty? - return Locale::Tag::Posix.parse(env).charset + tag = Private.parse(env) + next if tag.nil? + return tag.charset end nil end + + module Private + module_function + def parse(env_value) + return nil if env_value.nil? + return nil if env_value.empty? + Locale::Tag::Posix.parse(env_value) + end + end end MODULES[:env] = Env