Skip to content

Commit

Permalink
Add private module to provide helper methods
Browse files Browse the repository at this point in the history
  • Loading branch information
kou committed Sep 20, 2013
1 parent 6916573 commit b4b556e
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions lib/locale/driver/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit b4b556e

Please sign in to comment.