class RunLoop::Locale
@!visibility private
Constants
- LOCALES
@!visibility private
Generated using:
NSArray *identifiers = [[NSLocale availableLocaleIdentifiers]
sortedArrayUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
NSLocale *locale = [NSLocale localeWithLocaleIdentifier:@“en_US”]; for (NSString *localeId in identifiers) {
printf("\"%s\" => \"%s\",", [localeId cStringUsingEncoding:NSUTF8StringEncoding], [[locale displayNameForKey:NSLocaleIdentifier value:localeId] cStringUsingEncoding:NSUTF8StringEncoding]);
}
Attributes
@!visibility private
@!visibility private
Public Class Methods
@!visibility private Returns a locale instance given a device and locale code
Only codes supported by Apple are allowed.
@example
de => German de_CH => Switzerland
@param [RunLoop::Device] device the target device @param [String] locale_code identifies the code you want.
@return [RunLoop::Locale] a locale instance.
@raise [ArgumentError] if locale_code does not exist. @raise [ArgumentError] if the device iOS version is not supported.
# File lib/run_loop/locale.rb, line 40 def self.locale_for_code(locale_code, device) version = device.version locales = self.valid_locales(version) match = locales[locale_code] if match.nil? raise ArgumentError, %Q{There are no locales with code '#{locale_code}' for iOS version #{version.to_s}} end RunLoop::Locale.new(locale_code, match) end
@!visibility private
# File lib/run_loop/locale.rb, line 11 def initialize(code, name) @code = code @name = name end
@!visibility private Returns a list of locale objects given an iOS version.
@param [RunLoop::Version] ios_version the version @return [Hash] a hash of locale code => locale name
# File lib/run_loop/locale.rb, line 59 def self.valid_locales(ios_version) major_version = ios_version.major key = RunLoop::Version.new("#{major_version}.0") value = LOCALES[key] if value.nil? raise ArgumentError, "There are no locales for iOS version: #{ios_version.to_s}" else value end end
Public Instance Methods
# File lib/run_loop/locale.rb, line 20 def inspect to_s end
# File lib/run_loop/locale.rb, line 16 def to_s "<#Locale (#{code}) #{name}>" end