Class: PackerFiles::Core::Locale
- Defined in:
- lib/PackerFiles/Core/Locale.rb
Overview
Define the Locale class that can handle locales specified in a Packerfile. Just the barebones attributes that are required for this class are specified here. The conversion of these attributes into a OS build specific file is done by derived classes in the OS specific directories.
Instance Attribute Summary collapse
-
#country ⇒ Object
Returns the value of attribute country.
-
#default ⇒ Object
Specify attributes.
-
#language ⇒ Object
Returns the value of attribute language.
-
#supported ⇒ Object
Returns the value of attribute supported.
Class Method Summary collapse
-
.doc_file ⇒ Object
Documentation for this class.
Instance Method Summary collapse
-
#initialize {|_self| ... } ⇒ Locale
constructor
Constructor to just specify accessor varibales.
-
#normalize(utf = true, str = '.UTF-8') ⇒ Object
Normalize the various values into something useful.
Constructor Details
#initialize {|_self| ... } ⇒ Locale
Constructor to just specify accessor varibales
26 27 28 29 |
# File 'lib/PackerFiles/Core/Locale.rb', line 26 def initialize @supported = [] yield self if block_given? end |
Instance Attribute Details
#country ⇒ Object
Returns the value of attribute country.
17 18 19 |
# File 'lib/PackerFiles/Core/Locale.rb', line 17 def country @country end |
#default ⇒ Object
Specify attributes
15 16 17 |
# File 'lib/PackerFiles/Core/Locale.rb', line 15 def default @default end |
#language ⇒ Object
Returns the value of attribute language.
16 17 18 |
# File 'lib/PackerFiles/Core/Locale.rb', line 16 def language @language end |
#supported ⇒ Object
Returns the value of attribute supported.
18 19 20 |
# File 'lib/PackerFiles/Core/Locale.rb', line 18 def supported @supported end |
Class Method Details
.doc_file ⇒ Object
Documentation for this class
21 22 23 |
# File 'lib/PackerFiles/Core/Locale.rb', line 21 def self.doc_file PackerFiles.DirPath('Core/example/Locale.txt').first end |
Instance Method Details
#normalize(utf = true, str = '.UTF-8') ⇒ Object
Normalize the various values into something useful. Usually this means adding UTF-8 into the default string. if desired
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/PackerFiles/Core/Locale.rb', line 33 def normalize(utf = true, str='.UTF-8') # Concatenate language and country if the detailed notation # instead of the simpler one is preferred. if (!@language.nil? && !@country.nil?) @default = @language + '_' + @country end # If you need to add UTF prefixes, then add them to the # default locale. if (utf && !@default.end_with?(str)) @default = @default + str end # If you need to add UTF prefixes for all the supported # locales, do the same. @supported.map! {|x| if (utf && !x.end_with?(str)) x + str else x end } end |