Class: LittleWeasel::DictionaryKey
- Inherits:
-
Object
- Object
- LittleWeasel::DictionaryKey
- Includes:
- Modules::LanguageValidatable, Modules::Locale, Modules::RegionValidatable, Modules::Taggable
- Defined in:
- lib/LittleWeasel/dictionary_key.rb
Overview
This class describes a unique key associated with a particular dictionary file. Dictionary keys are used to identify a dictionary on which an action should be performed.
Instance Attribute Summary collapse
-
#language ⇒ Object
Returns the value of attribute language.
-
#region ⇒ Object
Returns the value of attribute region.
Attributes included from Modules::Taggable
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(language:, region: nil, tag: nil) ⇒ DictionaryKey
constructor
A new instance of DictionaryKey.
- #key ⇒ Object
- #to_s ⇒ Object
Methods included from Modules::Taggable
Methods included from Modules::TagValidatable
Methods included from Modules::RegionValidatable
#validate_region, validate_region
Methods included from Modules::Locale
Methods included from Modules::Region
#normalize_region, normalize_region, #normalize_region!, #region?
Methods included from Modules::Language
#language?, #normalize_language, normalize_language, #normalize_language!
Methods included from Modules::LanguageValidatable
#validate_language, validate_language
Constructor Details
#initialize(language:, region: nil, tag: nil) ⇒ DictionaryKey
Returns a new instance of DictionaryKey.
20 21 22 23 24 25 26 27 28 29 |
# File 'lib/LittleWeasel/dictionary_key.rb', line 20 def initialize(language:, region: nil, tag: nil) validate_language language: language self.language = normalize_language language validate_region region: region self.region = normalize_region region validate_tag tag: tag self.tag = tag end |
Instance Attribute Details
#language ⇒ Object
Returns the value of attribute language.
18 19 20 |
# File 'lib/LittleWeasel/dictionary_key.rb', line 18 def language @language end |
#region ⇒ Object
Returns the value of attribute region.
18 19 20 |
# File 'lib/LittleWeasel/dictionary_key.rb', line 18 def region @region end |
Class Method Details
.key(language:, region: nil, tag: nil) ⇒ Object
39 40 41 |
# File 'lib/LittleWeasel/dictionary_key.rb', line 39 def key(language:, region: nil, tag: nil) new(language: language, region: region, tag: tag).key end |
Instance Method Details
#key ⇒ Object
31 32 33 34 35 |
# File 'lib/LittleWeasel/dictionary_key.rb', line 31 def key return locale unless tagged? "#{locale}-#{tag}" end |
#to_s ⇒ Object
36 37 38 39 40 |
# File 'lib/LittleWeasel/dictionary_key.rb', line 36 def key return locale unless tagged? "#{locale}-#{tag}" end |