Class: AdLocalize::Entities::LocaleWording
- Inherits:
-
Object
- Object
- AdLocalize::Entities::LocaleWording
- Defined in:
- lib/ad_localize/entities/locale_wording.rb
Instance Attribute Summary collapse
-
#adaptives ⇒ Object
readonly
Returns the value of attribute adaptives.
-
#info_plists ⇒ Object
readonly
Returns the value of attribute info_plists.
-
#is_default ⇒ Object
readonly
Returns the value of attribute is_default.
-
#locale ⇒ Object
readonly
Returns the value of attribute locale.
-
#plurals ⇒ Object
readonly
Returns the value of attribute plurals.
-
#singulars ⇒ Object
readonly
Returns the value of attribute singulars.
Instance Method Summary collapse
- #add_wording(key:, value:, comment:) ⇒ Object
-
#initialize(locale:, is_default:) ⇒ LocaleWording
constructor
A new instance of LocaleWording.
- #to_s ⇒ Object
Constructor Details
#initialize(locale:, is_default:) ⇒ LocaleWording
Returns a new instance of LocaleWording.
7 8 9 10 11 12 13 14 |
# File 'lib/ad_localize/entities/locale_wording.rb', line 7 def initialize(locale:, is_default:) @locale = locale @is_default = is_default @singulars = {} # label => SimpleWording @info_plists = {} # label => SimpleWording @plurals = Hash.new { |hash, key| hash[key] = {} } # label: String => { variant_name: String => SimpleWording } @adaptives = Hash.new { |hash, key| hash[key] = {} } # label: String => { variant_name: String => SimpleWording } end |
Instance Attribute Details
#adaptives ⇒ Object (readonly)
Returns the value of attribute adaptives.
5 6 7 |
# File 'lib/ad_localize/entities/locale_wording.rb', line 5 def adaptives @adaptives end |
#info_plists ⇒ Object (readonly)
Returns the value of attribute info_plists.
5 6 7 |
# File 'lib/ad_localize/entities/locale_wording.rb', line 5 def info_plists @info_plists end |
#is_default ⇒ Object (readonly)
Returns the value of attribute is_default.
5 6 7 |
# File 'lib/ad_localize/entities/locale_wording.rb', line 5 def is_default @is_default end |
#locale ⇒ Object (readonly)
Returns the value of attribute locale.
5 6 7 |
# File 'lib/ad_localize/entities/locale_wording.rb', line 5 def locale @locale end |
#plurals ⇒ Object (readonly)
Returns the value of attribute plurals.
5 6 7 |
# File 'lib/ad_localize/entities/locale_wording.rb', line 5 def plurals @plurals end |
#singulars ⇒ Object (readonly)
Returns the value of attribute singulars.
5 6 7 |
# File 'lib/ad_localize/entities/locale_wording.rb', line 5 def singulars @singulars end |
Instance Method Details
#add_wording(key:, value:, comment:) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/ad_localize/entities/locale_wording.rb', line 16 def add_wording(key:, value:, comment:) wording = SimpleWording.new(key: key, value: value, comment: comment) case key.type when WordingType::PLURAL @plurals[key.label][key.variant_name] = wording when WordingType::ADAPTIVE @adaptives[key.label][key.variant_name] = wording when WordingType::INFO_PLIST @info_plists[key.label] = wording else @singulars[key.label] = wording end end |
#to_s ⇒ Object
31 32 33 34 35 36 37 |
# File 'lib/ad_localize/entities/locale_wording.rb', line 31 def to_s "Locale\nis default: #{is_default}\n==========\n" + "Singulars\n#{singulars}\n==========\n" + "InfoPlists\n#{info_plists}\n==========\n" + "Plurals\n#{plurals}\n==========\n" + "Adaptives\n#{adaptives}\n==========\n" end |